Boost logo

Boost :

Subject: [boost] clang-win clang-cl.exe on Windows 10 - is it time to add clang-win to the Boost test matrix?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2019-02-27 16:55:22


Confirming the work of others (pdimov and degski et al), I am now getting good results using clang-win (Clang 8.0.0 rc using GCC
provided by Mingw64) on Windows 10. (Clang 8.0.0 should be finally released very soon now).

Working the develop branch (fully up-to-date), I can run the Boost.Math examples and tests, and build the a set of most libraries

(4 versions of most, for example)
27-Feb-19 14:32 15,872 boost_atomic-clangw8-mt-d-x64-1_70.dll
27-Feb-19 14:32 2,442 boost_atomic-clangw8-mt-d-x64-1_70.lib
27-Feb-19 14:32 9,728 boost_atomic-clangw8-mt-x64-1_70.dll
27-Feb-19 14:32 2,420 boost_atomic-clangw8-mt-x64-1_70.lib

 (but there are some failures to compile or to link).

Examples in Addendum below:

My user-config.jam contains

  using clang-win
     : # Clang Version.
       8.0.0
     : # Location of Clang compiler .exe file(s). Must use clang-cl driver, not clang++.exe
       # Copied path is "C:\LLVM\clang-700\LLVM\bin\clang-cl.exe"
       "C:/LLVM/clang-800/LLVM/bin/clang-cl.exe"
       -fuse-ld=lld # Use lld linker https://lld.llvm.org/, not clang++.
       #

     : # Options.
       <cxxflags>-v # Verbose output for testing only. ? --verbose does not work for clang?
      # <define>BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
      # <compileflags>-m64 Use address-model=64 on command line.
       <compatibility>vc14 # MS version compatibility.
       <cxxflags>-fmsc-version=1915
       <cxxflags>-fms-compatibility
       <cxxflags>-fno-delayed-template-parsing
       #https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-s
       # options are -flto, -flto=full, -flto=thin, -emit-llvm
       # Generate output files in LLVM formats, suitable for link time optimization.
       # The default for -flto is "full", in which the LLVM bitcode is suitable for monolithic Link Time Optimization (LTO),
       # where the linker merges all such modules into a single combined module for optimization.
      # With "thin", ThinLTO compilation is invoked instead.
       <cxxflags>-flto=thin
       # MS clang-cl compatibility settings:
       <cxxflags>"/std:c++17" # Must be c++17, not earlier.
       <cxxflags>"/Zc:forScope"
       <cxxflags>"/Zc:wchar_t"
       <cxxflags>"/EHsc" # exception handling
       # https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model
       # (/EHsc), catches C++ exceptions only and tells the compiler to assume that
       # functions declared as extern "C" never throw a C++ exception.
       <cxxflags>"/Zc:inline"
       <cxxflags>"/Gd"
       <cxxflags>"/diagnostics:classic"

       # Clang flags:
       # https://clang.llvm.org/docs/ClangCommandLineReference.html#compilation-flags
       # <cxxflags>-std=c++17 - already declared as a MS option.
       <cxxflags>-Wno-deprecated
       <cxxflags>-Wno-delete-non-virtual-dtor
       # <cxxflags>-fmacro-backtrace-limit=0
       # <cxxflags>-Wno-invalid-token-paste
       <cxxflags>-Wno-language-extension-token
       <cxxflags>-Wno-microsoft-enum-value
       <cxxflags>-Wno-literal-range
       <cxxflags>-Wno-unknown-pragmas
       <cxxflags>-Wno-unused-variable
       <cxxflags>-Wno-microsoft-enum-value
       # <cxxflags>-Wno-invalid-constexpr # Need to stop reporting an error in Boost.System?
       <cxxflags>-Wno-unknown-argument
       <cxxflags>-Wno-unknown-pragmas
       <cxxflags>-Wno-macro-redefined
       <cxxflags>-Wno-unused-variable
       <cxxflags>-Wno-mismatched-tags
       <cxxflags>-Wno-deprecated-declarations

       <define>_CRT_SECURE_NO_DEPRECATE
       <define>_CRT_SECURE_NO_WARNINGS

# Not all these may be needed to get a mostly warning-free build.
...

My build command is

\modular-boost>b2 -j4 toolset=clang-win-8.0.0 address-model=64 architecture=x86 --libdir=I:/modular-boost/lib --build-type=complete
--without=mpi --without=python install 1>../boost_clang-win-8.0.0_64_config_27-Feb-19_1507.log

I wonder if this means that it is time to add clang-win-8 configuration to the Boost Test summary at

https://www.boost.org/development/tests/develop/developer/summary.html

?

Paul

PS What I have failed to get working is __float128 which works using GCC, but even after a patch enabling Clang in multiprecision's
config and ensuring that quadmath.h is visible to the Clang compiler. It reports "not supported" :-(

I have enquired if any progress can be made on making this work.

Addendum - problem examples:
========================

LLVM ERROR: Associative COMDAT symbol '??_7codecvt_error_cat@?A0x15DB13AB@@6B@' does not exist.

lld-link: error: undefined symbol: __imp_CryptGenRandom
>>> referenced by I:\modular-boost\libs\random\src\random_device.cpp:121
>>> lto.tmp:("public: unsigned int __cdecl boost::random::random_device::impl::next(void)"
(?next_at_impl@random_device_at_random@boost@@QEAAIXZ))
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)

         "C:/LLVM/clang-800/LLVM/bin/clang-cl.exe" "-fuse-ld=lld" -m64 /link /incremental:no /DLL /DEBUG /subsystem:console
/out:"bin.v2\libs\random\build\clang-win-8.0.0\debug\address-model-64\threading-multi\boost_random-clangw8-mt-d-x64-1_70.dll"
/IMPLIB:"bin.v2\libs\random\build\clang-win-8.0.0\debug\address-model-64\threading-multi\boost_random-clangw8-mt-d-x64-1_70.lib"
@"bin.v2\libs\random\build\clang-win-8.0.0\debug\address-model-64\threading-multi\boost_random-clangw8-mt-d-x64-1_70.dll.rsp"
        if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

and most annoyingly, since Boost.Test is a key library,

"I:\modular-boost\lib\boost_unit_test_framework-clangw8-mt-d-x64-1_70.dll"
"I:\modular-boost\lib\boost_unit_test_framework-clangw8-mt-d-x64-1_70.lib"

but no release variants :-(

clang-win.link.dll
bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_70.dll
LLVM ERROR: Associative COMDAT symbol '??_7results_reporter_impl@?A0x22C2280D_at_results_reporter_at_unit_test_at_boost@@6B@' does not exist.
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)

         "C:/LLVM/clang-800/LLVM/bin/clang-cl.exe" "-fuse-ld=lld" -m64 /link /incremental:no /DLL /subsystem:console
/out:"bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_70.
dll"
/IMPLIB:"bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_
70.lib"
@"bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_70.dll.
rsp"
        if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
    
...failed clang-win.link.dll
bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_70.dll
bin.v2\libs\test\build\clang-win-8.0.0\release\address-model-64\threading-multi\boost_unit_test_framework-clangw8-mt-x64-1_70.lib...

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk