-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang-cl: Fix #739 compatibility macros & add to AppVeyor #741
Conversation
@Farwaykorse thanks for the fix, can we also add test cases in appveyor.yml to make this always true? |
Compiling with clang-cl in Appveyor seems possible, but I don't have any experience with this. |
3deac31
to
7347fc5
Compare
I've made an error while reordering the options. |
Temporarily disable msvc compilation for faster testing (microsoft#741)
Temporarily disable msvc compilation for faster testing (microsoft#741)
d280c16
to
1a15d74
Compare
Issue with lld-link and the vcpkg install: |
301b41c
to
84f5794
Compare
0422f5e
to
f810ce7
Compare
Since CMake v3.0 use of Clang for both is deprecated
Changes:
|
This reverts commit 2238c47.
@Farwaykorse I will resolve conflicts caused by my changes. Thanks @Farwaykorse! |
added PR #762 to resolve conflicts |
Thanks @annagrin and @CaseyCarter for your friendly and constructive feedback. |
* Added c++17 test configurations for clang5.0 and clang6.0 * Fix #739 correct cppcorecheck warnings for clang-cl * Add clang-cl configurations * Corrections Appveyor; Temporarily disable msvc compilation for faster testing (#741) * Add path to clang-cl.exe (#741) * Escape backslash in path (#741) * Update vcpkg (#741) * Check vcpkg version; try without building vcpkg; use latest clang-cl from path (#741) * Fix blocks in ps script (#741) * Try accessing APPVEYOR_BUILD_FOLDER variable (#471) * Update span size() bug confirmation test for GCC 6.5 (#741) * MSVC flags to Clang-cl; disable c++98-compat and undefined macro warnings (#741) * Suppress clang warning on tests (missing-prototypes) (#741) * Fix clang warning -Wnewline-eof (#741) * Fix clang warning -Wdouble-promotion (#741) * Set linker explicitly * Clean condition statement * For Clang, fallback to the AppVeyor installed version of CMake * Fix clang warning -Wmissing-variable-declarations * Fallback to the MSVC linker until vcpkg has been updated * Revert "Fallback to the MSVC linker until vcpkg has been updated" This reverts commit 7263f32. * Fix clang warning -Wunused-member-function * Fix clang warning -Wmissing-noreturn * Fix clang warning -Winvalid-noreturn on Windows * Add macro block end comment on large #if blocks * Workaround: fallback to mscv link.exe * Workaround: get msvc paths into PowerShell through intermediate file * Workaround: fix, remove "PATH=" from text * Workaround: try with full-path; and return user PATH * Workaround: fix, escape backslashes * Revert all since "Workaround: fallback to mscv link.exe" did not work on AppVeyor This reverts the commits: bda3d6a 9706293 0f4fb04 1b0c19a a5739ea * Suppress output of git pull; remove vcpkg from cache * Re-enable AppVeyor builds for all platforms * Correct typo Co-Authored-By: Farwaykorse <Farwaykorse@users.noreply.github.com> * Add Clang-cl 7.0.0 to the supported platforms * Revert "Fix clang warning -Wunused-member-function" This reverts commit 6fe1a42. * Fix or locally suppress clang warning -Wunused-member-function * format touched code and correct comment * git pull --quiet * fix logic error in workaround * fix missing bracket * Suppress output of mkdir * Replace MSBuild with Ninja * Suppress output of 7z * Add architecture flags for Clang * Drop workaround for lld-link * 7-zip Overwrite and Alternative output suppression without suppressing errors Replaces 3c1c079 * AppVeyor setup and CMake before build * reorder compiler configuration * remove unnecessary * remove -fno-strict-aliasing * remove -Wsign-conversion, since before v4.0 part of -Wconversion * -Wctor-dtor-privacy is GCC only * remove -Woverloaded-virtual part of -Wmost, part of -Wall * add -Wmissing-noreturn * remove the pragmas for -Wunused-member-function * Re-add MSBuild generator on AppVeyor * Print CMake commands * Add MSBuild toolset selection * Separate Architecture setting * clang-cl: add -Weverything * clang-cl -Wno-c++98-compat * clang-cl -Wno-c++98-compat-pedantic * clang-cl -Wno-missing-prototypes * clang-cl C++14 -Wno-unused-member-function * clang-cl -Wundef __GNUC__ * clang++: add -Weverything * clang++ -Wno-c++98-compat * clang++ -Wno-c++98-compat-pedantic * clang++ -Wno-missing-prototypes * clang++ -Wno-weak-vtables * clang++ C++14 -Wno-unused-member-function * clang++ fix -Wundef _MSC_VER * clang++ -Wno-padded * clang++ solve -Wdeprecated * Add AppleClang compiler target Since CMake v3.0 use of Clang for both is deprecated * clang++ v5.0 C++17 -Wno-undefined-func-template * Add VS2015 + LLVM/clang-cl to AppVeyor * Do not disable constexpr when compiling with clang-cl on Windows * Clean-up clang-only warnings (now under -Weverything) * Revert "Fix clang warning -Winvalid-noreturn on Windows" This reverts commit 2238c47. * Suppress -Winvalid-noreturn for the MS STL noexception workaround * CMake: put preprocessor definition in target_compile_definitions * Solve compiler warning C4668: __GNUC__ not defined
* Changed GSL to reference master branch * microsoft/GSL#741 * TravisCI windows build
As described in #739.
When building on Windows with clang-cl.exe (the compatible replacement for cl.exe), both the macros
_MSC_VER
and__clang__
are defined.To get the temporary compatibility fix (#703) working with clang-cl, the check for
__clang__
has to come first.Adding compilation tests with AppVeyor:
Build 26: on Linux
COMPILER=g++-6 BUILD_TYPE=Release GSL_CXX_STANDARD=14
Resolves [Travis CI] Test broken size fails with GCC 6.5 #745
Using the VS 2017 and the LLVM toolset integration (vs extension available on AppVeyor). This tests the use of clang-cl from VS projects.
Temporary fix for the lld-linker and vcpkg (version installed on AppVeyor)--> No issue with Ninja(link using link.exe or update the installed vcpkg version)Replace thegit pull
of vcpkg with a fallback to the msvc linkerWorks locally but can't get it working on AppVeyor.
Therefore sticking with pulling vcpkg.--> NinjaThe--> Ninjagit pull
command on AppVeyor appears to generate a 'remote exception' bce6ed2-fno-exceptions
is not recognised by clang-cl'; results in:-Wunknown-argument
100f2b9-std=c++1z
; ...clang-cl.exe : error : unknown argument ignored in clang-cl: '-std=c++1z' [-Werror,-Wunknown-argument]
Fix: When building with clang-cl use the version of CMake installed on AppVeyor (v3.12.2) . 9a625ab
Is there a reason for using CMake v3.8.0? Yes: Issue CMake version #487 discusses the use of older CMake versions to ensure accessibility.
-Winvalid-noreturn
2238c47 Enabled by Defaultgsl\include\gsl/gsl_assert(123): error : function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
-Wnewline-eof
137367b -Weverythinggsl\tests\multi_span_tests.cpp(1785): error : no newline at end of file [-Werror,-Wnewline-eof]
-Wunused-member-function
337a03c -Weverythinggsl\tests\span_tests.cpp(57): error : unused member function 'operator&' [-Werror,-Wunused-member-function]
-Wdouble-promotion
f810ce7 -Weverythinggsl\tests\notnull_tests.cpp(196): error : implicit conversion increases floating-point precision: 'float' to 'double' [-Werror,-Wdouble-promotion]
-Wmissing-noreturn
1b15a73 -Weverythinggsl\tests\no_exception_ensure_tests.cpp(29): error : function 'test_terminate' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
gsl\tests\no_exception_throw_tests.cpp(28): error : function 'test_terminate' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
-Wmissing-variable-declarations
329da83 -Weverythinggsl\tests\utils_tests.cpp(83): error : no previous extern declaration for non-static variable 'j' [-Werror,-Wmissing-variable-declarations]
Extra:
Replace MSBuild withAdd Ninja-build. AppVeyor execution time reduction with 60%.Cmake issue: Ninja generator fails with clang-cl when mixing 64/32 bit clang and Visual Studio Environment
Improvements: (After review by annagrin)
+ 'flatter' decision structure; - some duplication; + more specific to each compiler
Note:
/W4
enables-Wall
and-Wextra
. 2bdb8f9 767f34c 595a726-fno-strict-aliasing
no issues building without it. b1e63fd-Wunused-member-function
fromspan_tests.cpp
to configuration.note: With
-Weverything
add:$<$<EQUAL:${GSL_CXX_STANDARD},14>:-Wno-unused-member-function>
c98c546-Wno-*
flags? - Local issue.Remove flags. 7b85156- pushed warning level.Find first working CMake version.Proper flags for clang-cl. v7.0.0 does not recognize-std=c++1z
.Both CMake and clang on AppVeyor are updated regularly. Unless both can be pinned, similar issues will appear again. Besides, this exercises the usage of the latest CMake release.
-Weverything
9ef9808-Wc++98-compat
and-Wc++98-compat-pedantic
57ac640, bef30b8-Wmissing-prototypes
in tests f96eca3-Wundef
on macro__GNUC__
a987075-Weverything
-Wweak-vtables
- suppressed fcbbe1f-Wundef
on macro_MSC_VER
eb60986-Wpadded
in gsl_util:51 and multi_span:1231 - suppressed fe882ce-Wundefined-func-template
only in clang v5.0.2. e7812cb-Wdeprecated
solved e7812cb-Wkeyword-macro
Clang does not require theconstexpr
disabling macro. f40a69eResolves #739