Skip to content

Commit

Permalink
Fix MSVC CLI builds as run by the regression system. (#912)
Browse files Browse the repository at this point in the history
* Fix MSVC CLI builds as run by the regression system.

+ After upgrading to Microsoft Visual Studio 2019 16.8.0 Preview 3, the
  regression system could no longer build Draco due to build errors reported in
  system headers pulled in by `rng/test`.  This version of MSVC also pulls in
  a newer version of CMake.
+ It was determined that these build errors could be eliminated by registering
  the rng unit tests as C++ files instead of C files, even though their file
  extensions are `.c`.
+ Also add a couple of new warning suppressions for MSVC.  The new version is
  more agressive in reporting warnings.  Only suppress issues found in the
  Random123 header files (we don't need to fix the TPL code).

* more cleanup for msvc build.

* Go back to registering as C for all compilers except MSVC. Exclude ut_gsl.c for MSVC.
  • Loading branch information
KineticTheory authored Sep 22, 2020
1 parent 144d4df commit f8ea72a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 32 deletions.
32 changes: 14 additions & 18 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"environments": [
{
"BuildDir": "${env.USERPROFILE}\\vs2019",
"projectname": "draco",
"install_subdir": "install/d"
"BuildDir": "${env.work_dir}",
"projectname": "draco",
"install_subdir": "install",
"cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake"
}
],
"configurations": [
Expand All @@ -12,54 +13,49 @@
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${env.BuildDir}/${name}/${env.projectname}",
"installRoot": "${env.BuildDir}/${name}/${env.install_subdir}",
"buildRoot": "${env.BuildDir}/${env.projectname}/${name}",
"installRoot": "${env.BuildDir}/${env.projectname}/${env.install_subdir}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-verbosity:minimal -m:${env.NUMBER_OF_PROCESSORS}",
"ctestCommandArgs": "-j ${env.NUMBER_OF_PROCESSORS} --output-on-failure",
"cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake",
"variables": [],
"cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe"
"variables": []
},
{
"name": "x64-Release",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Release",
"buildRoot": "${env.BuildDir}/${name}/${env.projectname}",
"installRoot": "${env.BuildDir}/${name}/${env.install_subdir}",
"buildRoot": "${env.BuildDir}/${env.projectname}/${name}",
"installRoot": "${env.BuildDir}/${env.projectname}/${env.install_subdir}",
"cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe",
"cmakeCommandArgs": "",
"buildCommandArgs": "-verbosity:minimal -m:${env.NUMBER_OF_PROCESSORS}",
"ctestCommandArgs": "-j ${env.NUMBER_OF_PROCESSORS} --output-on-failure",
"cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
},
{
"name": "x64-Debug-scalar",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"buildRoot": "${env.BuildDir}/${name}/${env.projectname}",
"installRoot": "${env.BuildDir}/${name}/${env.install_subdir}",
"buildRoot": "${env.BuildDir}/${env.projectname}/${name}",
"installRoot": "${env.BuildDir}/${env.projectname}/${env.install_subdir}",
"cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe",
"cmakeCommandArgs": "-DDRACO_C4=SCALAR",
"buildCommandArgs": "-verbosity:minimal -m:${env.NUMBER_OF_PROCESSORS}",
"ctestCommandArgs": "-j ${env.NUMBER_OF_PROCESSORS} --output-on-failure",
"cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
},
{
"name": "x64-Clang-Debug",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"buildRoot": "${env.BuildDir}/${name}/${env.projectname}",
"installRoot": "${env.BuildDir}/${name}/${env.install_subdir}",
"buildRoot": "${env.BuildDir}/${env.projectname}/${name}",
"installRoot": "${env.BuildDir}/${env.projectname}/${env.install_subdir}",
"cmakeExecutable": "C:/Program Files/CMake/bin/cmake.exe",
"cmakeCommandArgs": "-DCMAKE_C_COMPILER:FILEPATH=\"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/PREVIEW/VC/Tools/Llvm/x64/bin/clang-cl.exe\"",
"cmakeCommandArgs": "-DCMAKE_C_COMPILER:FILEPATH=\"C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/PREVIEW/VC/Tools/llvm/x64/bin/clang-cl.exe\"",
"buildCommandArgs": "-v:m -m:${env.NUMBER_OF_PROCESSORS} ",
"ctestCommandArgs": "-j ${env.NUMBER_OF_PROCESSORS} --output-on-failure",
"cmakeToolchain": "C:/work/vendors64/vs2019-toolchain.cmake",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"intelliSenseMode": "windows-clang-x64",
"variables": []
Expand Down
32 changes: 26 additions & 6 deletions src/rng/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# author Kelly Thompson <[email protected]>
# date 2012 Aug 1
# brief Generate build project files for rng/test.
# note Copyright (C) 2016-2019, Triad National Security, LLC.
# All rights reserved.
# note Copyright (C) 2016-2019, Triad National Security, LLC., All rights reserved.
#--------------------------------------------------------------------------------------------------#
project( rng_test C CXX )

Expand All @@ -23,14 +22,24 @@ set( random123_unit_tests
${PROJECT_SOURCE_DIR}/ut_aes.cpp
${PROJECT_SOURCE_DIR}/ut_ars.c
${PROJECT_SOURCE_DIR}/ut_carray.cpp
${PROJECT_SOURCE_DIR}/ut_gsl.c
${PROJECT_SOURCE_DIR}/ut_M128.cpp
${PROJECT_SOURCE_DIR}/ut_uniform.cpp
)

# [2020-08-21 KT] The code in ut_gsl.c is not valid C++. Because this test is a mix of C and C++,
# it causes issues. Most compilers are happy to compile this code with C, visual studio is not.
# When marked as C++, this test fails with:
#
# "C:\projects\draco\src\rng\test\ut_gsl.c(62,1): error C2086: 'const gsl_rng_type \
# *gsl_rng_cbrng': redefinition"
#
# Indeed, reviewing the Random123 file gsl_cbrng.h reveals that that gsl_rng_type is declared twice,
# first on line 68 and then again on line 125 (with an assignment this time). We can continue
# building and running this tests on platforms that can processs it (all but MSVC right now).
if( NOT MSVC )
list(APPEND random123_unit_tests ${PROJECT_SOURCE_DIR}/ut_gsl.c )
endif()
if( R123_USE_CXX11 )
list( APPEND random123_unit_tests
${PROJECT_SOURCE_DIR}/ut_Engine.cpp )
list( APPEND random123_unit_tests ${PROJECT_SOURCE_DIR}/ut_Engine.cpp )
endif()

# Random123 known-answer tests
Expand All @@ -39,6 +48,17 @@ set( random123_known_answer_tests
${PROJECT_SOURCE_DIR}/kat_cpp.cpp
)

# Some compilers (esp. MSVC) have trouble with compiling these files as C11 code, so tell cmake
# to treat them as C++14. ut_gsl.c has a bug that prevents it from compiling as C++, so we omit it
# from this list.
if( MSVC )
set_source_files_properties(
${PROJECT_SOURCE_DIR}/time_serial.c
${PROJECT_SOURCE_DIR}/ut_ars.c
${PROJECT_SOURCE_DIR}/kat_c.c
PROPERTIES LANGUAGE CXX )
endif()

#--------------------------------------------------------------------------------------------------#
# Build Unit tests
#--------------------------------------------------------------------------------------------------#
Expand Down
11 changes: 11 additions & 0 deletions src/rng/test/time_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "time_misc.h"
#include "util_print.h"

#ifdef _MSC_FULL_VER
// - 4505 :: 'warmupCPU': unreferenced local function has been removed.
#pragma warning(push)
#pragma warning(disable : 4505)
#endif

#include "util_cpu.h"

#define KERNEL R123_STATIC_INLINE
#define get_global_id(i) (i)
#include "time_random123.h"
Expand Down Expand Up @@ -165,6 +172,10 @@ int main(int argc, char **argv) {
#pragma GCC diagnostic pop
#endif

#ifdef _MSC_FULL_VER
#pragma warning(pop)
#endif

//------------------------------------------------------------------------------------------------//
// end time_serial.c
//------------------------------------------------------------------------------------------------//
5 changes: 3 additions & 2 deletions src/rng/test/time_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

#ifdef _MSC_FULL_VER
// - 4204 :: nonstandard extension used: non-constant aggregate initializer.
// - 4127 :: conditional expression is constant
#pragma warning(push)
#pragma warning(disable : 4204 4100)
#pragma warning(disable : 4204 4100 4127)
#endif

#include <Random123/aes.h>
#include <Random123/ars.h>
#include <Random123/philox.h>
#include <Random123/threefry.h>

#ifdef _MSC_FULL_VERf
#ifdef _MSC_FULL_VER
#pragma warning(pop)
#endif

Expand Down
4 changes: 3 additions & 1 deletion src/rng/test/ut_gsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef _MSC_FULL_VER
// 4311 - 'type cast': pointer truncation from 'char[54]' to 'long'
// 4202 - nonstandard extension used: non-constant aggregate initializer
// 4127 - conditional expression is constant
// 4302 - 'type cast': truncation from 'const char *' to 'long'
#pragma warning(push)
#pragma warning(disable : 4311 4204)
#pragma warning(disable : 4311 4204 4127 4302)
#endif

#include "rng/config.h"
Expand Down
7 changes: 2 additions & 5 deletions src/rng/test/ut_gsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
* \author Gabriel M. Rockefeller
* \date Tue Oct 9 19:02:09 2012
* \brief ut_gsl header file.
* \note Copyright (C) 2016-2020 Triad National Security, LLC
*/
/*------------------------------------------------------------------------------------------------*/
/* $Id$ */
* \note Copyright (C) 2016-2020 Triad National Security, LLC., All rights reserved. */
/*------------------------------------------------------------------------------------------------*/

#ifndef rng_test_ut_gsl_h
Expand All @@ -23,5 +20,5 @@
#endif /* rng_test_ut_gsl_h */

/*------------------------------------------------------------------------------------------------*/
/* end of rng/test/ut_gsl.h */
/* end of rng/test/ut_gsl.h */
/*------------------------------------------------------------------------------------------------*/

0 comments on commit f8ea72a

Please sign in to comment.