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

B2 fails to use quoted path invocation for the archiver program. #286

Open
walbourn opened this issue Apr 23, 2023 · 4 comments
Open

B2 fails to use quoted path invocation for the archiver program. #286

walbourn opened this issue Apr 23, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@walbourn
Copy link

walbourn commented Apr 23, 2023

Make sure you completed the following tasks

Environment and version details

  • Operating System+version: Windows 11
  • Compiler+version: clang/LLVM for Windows 15.0.1
  • CMake 3.25.1

Brief problem description

I'm working on implementing clang-cl triplets for the VCPKG manager, and encountered an issue unique to boost building. The problem is that I'm attempting to use the built-in Visual Studio version of clang-cl. In this scenario, the b2 tool is properly quoting and fixing-up the compiler and linker paths, but not the librarian paths.

Actual behavior summary

Via CMake, the toolset variables are set as follows:

CMAKE_AR:FILEPATH=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/llvm-lib.exe
CMAKE_CXX_COMPILER:STRING=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe
CMAKE_C_COMPILER:STRING=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe

The B2 summary prints out:

notice: [msvc-cfg] msvc-14.3 detected, command: 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe'
notice: [clang-win] using compiler '"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe"', version '143', target 'x86_64', default address-model=64
notice: will use 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe' for clang-win, condition <toolset>clang-win-143
notice: [clang-win] x86-32: using linker '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\Hostx64\\x86\\link.exe"'
notice: [clang-win] x86-32: using assembler '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\Hostx64\\x86\ml.exe"'
notice: [clang-win] x86-32: using archiver 'C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/llvm-lib.exe'

Note that linker and assembler are using quoted. archiver is not.

This results in the following build failure:

compile-c-c++ D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\clone_current_exception_non_intrusive.obj

     "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe" --target=x86_64-pc-windows-msvc "..\src\clone_current_exception_non_intrusive.cpp" -c -Fo"D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\clone_current_exception_non_intrusive.obj"     -TP /EHs /GR -nologo -DWIN32 -D_WINDOWS -W3 -utf-8 -GR -EHsc -MP -m64 -D_DEBUG -MDd -Z7 -Ob0 -Od -RTC1 /Z7 /Od /Ob0 /W3 /MDd -DBOOST_ALL_NO_LIB=1 "-I..\include" "-ID:\vcpkg\installed\x64-clangcl-dynamic\include" 

clang-cl: warning: argument unused during compilation: '-MP' [-Wunused-command-line-argument]

        if exist "D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\libboost_exception-clangw143-mt-gd-x64-1_82.lib" DEL "D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\libboost_exception-clangw143-mt-gd-x64-1_82.lib"
         C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/llvm-lib.exe /nologo  /out:"D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\libboost_exception-clangw143-mt-gd-x64-1_82.lib" "D:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4\clone_current_exception_non_intrusive.obj"   
    
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.
...skipped <pD:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\stage\lib>libboost_exception-clangw143-mt-gd-x64-1_82.lib for lack of <pD:\vcpkg\buildtrees\boost-exception\x64-clangcl-dynamic-dbg\boost\build\9ce0872fe7feae3839f2236f8df9a6f4>libboost_exception-clangw143-mt-gd-x64-1_82.lib...
...failed updating 1 target...
ninja: build stopped: subcommand failed.

The compiler got quoted in the shell execution but the archiver did not.

Expected behavior summary

It looks like when passed in from CMake, the non-native paths are kept, but because the compiler invocation is quoted it works. The archiver needs the same quoting.

@walbourn walbourn added the bug Something isn't working label Apr 23, 2023
@walbourn walbourn changed the title B2 fails to convert the archiver path to native Seperators and quote invocation B2 fails to convert the archiver path to native seperators and quote invocation Apr 23, 2023
@walbourn walbourn changed the title B2 fails to convert the archiver path to native seperators and quote invocation B2 fails to use quote invocation for the archiver program. Apr 23, 2023
@walbourn walbourn changed the title B2 fails to use quote invocation for the archiver program. B2 fails to use quoted path invocation for the archiver program. Apr 23, 2023
@Kojoley
Copy link
Contributor

Kojoley commented May 7, 2023

@grafikrobot do you it would be possible to automatically quote variable expansions in actions? At least just simple expansions and bail out on things where it catenates with words/varexps. Escaping for shells is so error prone that it needs some sort of a general solution. It probably also needs to support already quoted stuff so things like #309 won't happen.

@grafikrobot
Copy link
Member

grafikrobot commented Dec 16, 2023

@Kojoley one option is to have a special kind of expansion, in general, that does quoting, path, etc fixups after/around other expressions/variable. Maybe /($(a)/$(b).$(c)) (the "/" being the do path, quote, escape handling prefix). But I suspect it's not safe at this point to use that.

@grafikrobot
Copy link
Member

But ultimately.. avoiding using batch/shell invocation entirely by executing the command directly is the real solution.

@grafikrobot
Copy link
Member

@walbourn you say "Via CMake, the toolset variables are set as follows". How are you setting up b2 with those variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants