Skip to content
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

[bug] the wrong command line argument -stdlib=libstdc++ #9434

Open
arttet opened this issue Aug 17, 2021 · 21 comments
Open

[bug] the wrong command line argument -stdlib=libstdc++ #9434

arttet opened this issue Aug 17, 2021 · 21 comments

Comments

@arttet
Copy link

arttet commented Aug 17, 2021

There is the wrong command line argument -stdlib=libstdc++.

clang++: warning: argument unused during compilation: '-stdlib=libstdc++' [-Wunused-command-line-argument]

Environment Details (include every applicable attribute)

  • Windows Server 2019
  • Visual Studio 16 ClangCl or Clang 13
  • Conan version: 1.41.0
  • Python version: 3.9.6

Steps to reproduce (Include if Applicable)

conan install . --install-folder build --build=outdated -s build_type=Debug -s compiler.cppstd=17 -s compiler.version=16 -s compiler="Visual Studio" -s compiler.toolset=ClangCL -e CC=clang-cl -e CXX=clang-cl

@memsharded
Copy link
Member

Improving clang support in Windows is an open issue: #9295

It is not simple to change this, because it also depends on the build system integration, and there are risks of breaking things, so I would say to try to implement and fix this in the new conan.tools.xxx new integrations.

@dmn-star
Copy link

dmn-star commented Aug 17, 2021

@arttet This is because clang-cl does not support /MP. You should remove -Werror from the gtest recipe.

@memsharded The linked issue is about using standalone clang on windows not clang-cl, I think.

@dmn-star
Copy link

By the way, I cannot reproduce the errors locally. Perhaps try to update VS/CMake first and get the new versions of recipes (conan install . --install-folder build --build --update ...).

@arttet
Copy link
Author

arttet commented Aug 17, 2021

I was surprised because I cannot reproduce the errors locally too. However, I repeated it on GitHub. So I prepared the branch with my changes.

I noticed the difference between the local build and the GitHub build. I use VS 16.11 and Clang 12.0.0 with MSVC-like command-line. GitHub uses VS 16.10.2+857e5a733 and Clang 11.0.0 with MSVC-like command-line.

Anyway, I repeated a similar bug using Clang locally.

error: argument unused during compilation: '-stdlib=libstdc++'

@dmn-star
Copy link

Try to change In your CMakeLists.txt

if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
  add_compile_options(
    "-Wextra"
    "-Wall"
    "-Werror"
  )
endif()

to

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
    # using clang with clang-cl front end
  elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
    # using clang with regular front end
  endif()
endif()

@arttet
Copy link
Author

arttet commented Aug 17, 2021

I applied your patch, but the result remained the same.

2021-08-17T21:35:28.0391023Z Auto detecting your dev setup to initialize the default profile (C:\Users\runneradmin\.conan\profiles\default)
2021-08-17T21:35:28.4399848Z Found Visual Studio 16
2021-08-17T21:35:29.1320359Z Found gcc 8.1
2021-08-17T21:35:29.1451459Z Default settings
2021-08-17T21:35:29.1452390Z 	os=Windows
2021-08-17T21:35:29.1452924Z 	os_build=Windows
2021-08-17T21:35:29.1453422Z 	arch=x86_64
2021-08-17T21:35:29.1453900Z 	arch_build=x86_64
2021-08-17T21:35:29.1454434Z 	compiler=Visual Studio
2021-08-17T21:35:29.1455119Z 	compiler.version=16
2021-08-17T21:35:29.1455708Z 	build_type=Release
2021-08-17T21:35:29.1457230Z *** You can change them in C:\Users\runneradmin\.conan\profiles\default ***
2021-08-17T21:35:29.1458092Z *** Or override with -s compiler='other' -s ...s***
2021-08-17T21:35:29.1459036Z 
2021-08-17T21:35:29.1459357Z 
2021-08-17T21:35:29.2010522Z WARN: Remotes registry file missing, creating default one in C:\Users\runneradmin\.conan\remotes.json
2021-08-17T21:35:29.2021529Z Configuration:
2021-08-17T21:35:29.2022336Z [settings]
2021-08-17T21:35:29.2022891Z arch=x86_64
2021-08-17T21:35:29.2023357Z arch_build=x86_64
2021-08-17T21:35:29.2023854Z arch_target=x86_64
2021-08-17T21:35:29.2024357Z build_type=Debug
2021-08-17T21:35:29.2024909Z compiler=Visual Studio
2021-08-17T21:35:29.2025475Z compiler.cppstd=17
2021-08-17T21:35:29.2026200Z compiler.runtime=MTd
2021-08-17T21:35:29.2026906Z compiler.toolset=ClangCL
2021-08-17T21:35:29.2027544Z compiler.version=16
2021-08-17T21:35:29.2028110Z os=Windows
2021-08-17T21:35:29.2028593Z os_build=Windows
2021-08-17T21:35:29.2029093Z [options]
2021-08-17T21:35:29.2029595Z [build_requires]
2021-08-17T21:35:29.2030068Z [env]
2021-08-17T21:35:29.2030531Z CC=clang-cl
2021-08-17T21:35:29.2031002Z CXX=clang-cl
2021-08-17T21:35:29.2194407Z gtest/1.11.0: Not found in local cache, looking in remotes...
2021-08-17T21:35:29.2195374Z gtest/1.11.0: Trying with 'conancenter'...
2021-08-17T21:35:29.3924604Z Downloading conanmanifest.txt
2021-08-17T21:35:29.4045502Z Downloading conanfile.py
2021-08-17T21:35:29.4166595Z Downloading conan_export.tgz
2021-08-17T21:35:29.4374553Z gtest/1.11.0: Downloaded recipe revision 0
2021-08-17T21:35:29.4646615Z conanfile.py (reproduce-bug/0.0.0): Installing package
2021-08-17T21:35:29.4649745Z Requirements
2021-08-17T21:35:29.4651806Z Packages
2021-08-17T21:35:29.4652351Z Build requirements
2021-08-17T21:35:29.4653010Z     gtest/1.11.0 from 'conancenter' - Downloaded
2021-08-17T21:35:29.4657098Z Build requirements packages
2021-08-17T21:35:29.4657989Z     gtest/1.11.0:00e0939b3108050e1250e07d1b9be128b1bd1cbf - Build
2021-08-17T21:35:29.4658534Z 
2021-08-17T21:35:29.4660404Z Installing (downloading, building) binaries...
2021-08-17T21:35:29.4817088Z Downloading conan_sources.tgz
2021-08-17T21:35:29.5043571Z gtest/1.11.0: Configuring sources in C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\source
2021-08-17T21:35:29.7966224Z 
2021-08-17T21:35:30.1345952Z gtest/1.11.0: Copying sources to build folder
2021-08-17T21:35:30.3722721Z gtest/1.11.0: Building your package in C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf
2021-08-17T21:35:30.3734389Z gtest/1.11.0: Generator cmake created conanbuildinfo.cmake
2021-08-17T21:35:30.3739873Z gtest/1.11.0: Aggregating env generators
2021-08-17T21:35:30.3782069Z gtest/1.11.0: Calling build()
2021-08-17T21:36:16.1279487Z -- The C compiler identification is Clang 11.0.0 with MSVC-like command-line
2021-08-17T21:36:20.0065560Z -- The CXX compiler identification is Clang 11.0.0 with MSVC-like command-line
2021-08-17T21:36:20.2871449Z -- Detecting C compiler ABI info
2021-08-17T21:36:23.8226696Z -- Detecting C compiler ABI info - done
2021-08-17T21:36:23.8243611Z -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
2021-08-17T21:36:23.8255119Z -- Detecting C compile features
2021-08-17T21:36:23.8640267Z -- Detecting C compile features - done
2021-08-17T21:36:23.8768679Z -- Detecting CXX compiler ABI info
2021-08-17T21:36:26.9399603Z -- Detecting CXX compiler ABI info - done
2021-08-17T21:36:26.9417648Z -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
2021-08-17T21:36:26.9422953Z -- Detecting CXX compile features
2021-08-17T21:36:33.2450476Z -- Detecting CXX compile features - done
2021-08-17T21:36:33.2503099Z -- Conan: called by CMake conan helper
2021-08-17T21:36:33.2503968Z -- Conan: called inside local cache
2021-08-17T21:36:33.2504653Z -- Conan: Adjusting output directories
2021-08-17T21:36:33.2505362Z -- Conan: Using cmake global configuration
2021-08-17T21:36:33.2509175Z -- Conan: Adjusting default RPATHs Conan policies
2021-08-17T21:36:33.2510676Z -- Conan: Adjusting language standard
2021-08-17T21:36:33.2511382Z -- Conan setting CPP STANDARD: 17 WITH EXTENSIONS OFF
2021-08-17T21:36:33.2513090Z -- Conan: Skipping compiler check: Declared 'compiler.toolset'
2021-08-17T21:36:34.0362035Z -- Found Python: C:/hostedtoolcache/windows/Python/3.9.6/x64/python3.exe (found version "3.9.6") found components: Interpreter 
2021-08-17T21:36:34.0811949Z -- Looking for pthread.h
2021-08-17T21:36:37.1411117Z -- Looking for pthread.h - not found
2021-08-17T21:36:37.1432106Z -- Found Threads: TRUE  
2021-08-17T21:36:38.0155358Z CMake Warning:
2021-08-17T21:36:38.0156072Z   Manually-specified variables were not used by the project:
2021-08-17T21:36:38.0156844Z 
2021-08-17T21:36:38.0157457Z     CMAKE_EXPORT_NO_PACKAGE_REGISTRY
2021-08-17T21:36:38.0157958Z     CONAN_COMPILER_VERSION
2021-08-17T21:36:38.0158422Z     CUSTOM_DEBUG_POSTFIX
2021-08-17T21:36:38.0158716Z 
2021-08-17T21:36:38.0158908Z 
2021-08-17T21:36:38.0159310Z -- Configuring done
2021-08-17T21:36:38.0159747Z -- Generating done
2021-08-17T21:36:38.0160657Z -- Build files have been written to: C:/Users/runneradmin/.conan/data/gtest/1.11.0/_/_/build/00e0939b3108050e1250e07d1b9be128b1bd1cbf/build_subfolder
2021-08-17T21:36:38.0161700Z Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework
2021-08-17T21:36:38.0162447Z Copyright (C) Microsoft Corporation. All rights reserved.
2021-08-17T21:36:38.0162902Z 
2021-08-17T21:36:40.1555805Z   Checking Build System
2021-08-17T21:36:41.1023497Z   Building Custom Rule C:/Users/runneradmin/.conan/data/gtest/1.11.0/_/_/build/00e0939b3108050e1250e07d1b9be128b1bd1cbf/source_subfolder/googlemock/CMakeLists.txt
2021-08-17T21:36:41.4467697Z clang-cl : error : argument unused during compilation: '/MP2' [-Werror,-Wunused-command-line-argument] [C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder\source_subfolder\googlemock\gmock.vcxproj]
2021-08-17T21:36:41.4481840Z clang-cl : error : argument unused during compilation: '/MP2' [-Werror,-Wunused-command-line-argument] [C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder\source_subfolder\googlemock\gmock.vcxproj]
2021-08-17T21:36:41.6130872Z   Building Custom Rule C:/Users/runneradmin/.conan/data/gtest/1.11.0/_/_/build/00e0939b3108050e1250e07d1b9be128b1bd1cbf/source_subfolder/googletest/CMakeLists.txt
2021-08-17T21:36:41.6906938Z clang-cl : error : argument unused during compilation: '/MP2' [-Werror,-Wunused-command-line-argument] [C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder\source_subfolder\googletest\gtest.vcxproj]
2021-08-17T21:36:43.2839729Z   Building Custom Rule C:/Users/runneradmin/.conan/data/gtest/1.11.0/_/_/build/00e0939b3108050e1250e07d1b9be128b1bd1cbf/source_subfolder/googlemock/CMakeLists.txt
2021-08-17T21:36:43.5351307Z clang-cl : error : argument unused during compilation: '/MP2' [-Werror,-Wunused-command-line-argument] [C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder\source_subfolder\googlemock\gmock_main.vcxproj]
2021-08-17T21:36:43.5421555Z clang-cl : error : argument unused during compilation: '/MP2' [-Werror,-Wunused-command-line-argument] [C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder\source_subfolder\googlemock\gmock_main.vcxproj]
2021-08-17T21:36:43.6476347Z gtest/1.11.0: 
2021-08-17T21:36:43.6477324Z gtest/1.11.0: ERROR: Package '00e0939b3108050e1250e07d1b9be128b1bd1cbf' build failed
2021-08-17T21:36:43.6478802Z gtest/1.11.0: WARN: Build folder C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf
2021-08-17T21:36:43.6522988Z ERROR: gtest/1.11.0: Error in build() method, line 129
2021-08-17T21:36:43.6524195Z 	cmake.build()
2021-08-17T21:36:43.6525545Z 	ConanException: Error 1 while executing cmake --build C:\Users\runneradmin\.conan\data\gtest\1.11.0\_\_\build\00e0939b3108050e1250e07d1b9be128b1bd1cbf\build_subfolder --config Debug -- /m:2 /verbosity:minimal
2021-08-17T21:36:44.3550294Z ERROR: conanbuildinfo.txt file not found in D:\a\reproducing-bug\reproducing-bug\build
2021-08-17T21:36:44.3551478Z It is required for this command
2021-08-17T21:36:44.3552150Z You can generate it using 'conan install'
2021-08-17T21:36:44.3992272Z ##[error]Process completed with exit code 1.

@dmn-star
Copy link

dmn-star commented Aug 18, 2021

It also looks like the GNU style arguments are passed to clang-cl. I will have a look at this later.

clang-cl : error : argument unused during compilation: '/MP2'

Not sure but that seems to be fixed in clang 12.

@dmn-star
Copy link

dmn-star commented Aug 18, 2021

Case 1: Ok. clang_cl + cmake + visual studio generator
All works as expected on my machine and on github with small changes (I forked your repo).

Case 2: Failed. clang + cmake + ninja generator
I never used it that way. And I don't think that will work without further effort. @AndreyMlashkin trying to get this to work.
Are you sure you want to use clang (not clang_cl) ?

On my machine I got

error: argument unused during compilation: '-stdlib=libstdc++'

too.

@arttet
Copy link
Author

arttet commented Aug 18, 2021

Could you please use another branch such as bug/conan-clangcl? main is the empty prototype, and you need to update conanfile.py and CMakeLists.txt too.
I removed those variables, but my branch does not compile.

@arttet
Copy link
Author

arttet commented Aug 18, 2021

I think case 2 should be valid. We can download Clang on Windows. Therefore, I think we need to be able to compile code with it.

@dmn-star
Copy link

You can use my main branch, it works. Please check the changes.

@arttet
Copy link
Author

arttet commented Aug 18, 2021

I would like to say your branch compiles nothing. Therefore, it works well.

@arttet
Copy link
Author

arttet commented Aug 18, 2021

However, I can see the warning in your build.

clang-cl : warning : argument unused during compilation: '/MP2'

@dmn-star
Copy link

I think case 2 should be valid. We can download Clang on Windows. Therefore, I think we need to be able to compile code with it.

I know but we have only ever used clang-cl for our real-life projects. Maybe just try to compile a simple test program without Conan?

@dmn-star
Copy link

dmn-star commented Aug 18, 2021

However, I can see the warning in your build.

clang-cl : warning : argument unused during compilation: '/MP2'

Yes, CMake VS generator or Conan pass the /MP option to clang-cl, VS do not. See CMakeLists.txt for workaround

add_compile_options(  
  "-Wno-error=unused-command-line-argument"
  )

But with new clang_cl version this is not necessary any more.

@arttet
Copy link
Author

arttet commented Aug 18, 2021

I think case 2 should be valid. We can download Clang on Windows. Therefore, I think we need to be able to compile code with it.

I know but we have only ever used clang-cl for our real-life projects. Maybe just try to compile a simple test program without Conan?

I am sorry. I don’t get it. Anyway, I consider Clang as a competitor of MSVC. Clang has some advantages. Moreover, I hope Conan will help to use Clang.

@dmn-star
Copy link

clang_cl is clang too. :-) Clang on Windows uses Visual Studio's linker and SDK, so you still need to have Visual Studio installed. And as long as that is the case, it is much easier to use clang_cl.

@arttet
Copy link
Author

arttet commented Aug 19, 2021

Case 1 was fixed here.

@dmn-star
Copy link

This is of course a clean solution.

@memsharded
Copy link
Member

I am adding some tests for Clang into our test suite for new toolchains here: #9477
This is the future of Conan, so it would be great to make sure that things work there, and reduce to integrated unit-tests the desired behavior for different clang flavors, this is the only way to make sure that things work correctly.

@arttet
Copy link
Author

arttet commented Oct 28, 2021

Hi @memsharded, @dmn-star

Could you please update the status of this issue?

@arttet arttet changed the title [bug] the wrong command line argument '/MP2' for ClangCl [bug] the wrong command line argument -stdlib=libstdc++ Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants