xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.11k stars 784 forks source link

Package build failed if path to MinGW contains spaces #4745

Closed yh-sb closed 8 months ago

yh-sb commented 8 months ago

Xmake Version

2.8.6

Operating System Version and Architecture

Windows 11 Pro 23H2 22631.3155

Describe Bug

NOTE: there is no such error if MinGW-w64 is placed, for example, to C:/. In this case build is successful.

  1. Move MinGW toolchain to path with spaces. For example, C:/Program Files/mydevtools/MinGW-w64.
  2. Add C:/Program Files/mydevtools/MinGW-w64/bin to system PATH variable.
  3. Build project with xmake and boost package.
    xmake f -p mingw
  4. See that boost installation is failed

    checking for architecture ... x86_64
    checking for mingw directory ... C:\Program Files\mydevtools\MinGW-w64
    updating repositories .. ok
    note: install or modify (m) these packages (pass -y to skip confirm)?
    in xmake-repo:
      -> boost 1.84.0 [components:"asio"]
    please input: y (y/n/m)
    y
      => download https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz .. ok
      => install boost 1.84.0 .. failed
    
    boost build failed, please check log in C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\source\boost-log.txt
    if you want to get more verbose errors, please see:
      -> C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\installdir.failed\logs\install.txt
    error: install failed!

    with error in boost-log.txt:

    C:/Users/Y/AppData/Local/.xmake/cache/packages/2402/b/boost/1.84.0/source/tools/build/src/tools\common.jam:1104: in 
    common.find-compiler from module common
    error: toolset gcc initialization:
    error: provided command '"C:/Program" "Files/mydevtools/MinGW-w64/bin/x86_64-w64-mingw32-g++"' not found

    Looks like the quoted space in path "C:/Program" "Files/mydevtools/MinGW-w64/bin/x86_64-w64-mingw32-g++" is the root cause of boost failed build.

Expected Behavior

The build is successful.

Project Configuration

xmake.lua

add_rules("mode.debug", "mode.release")

-- Set default mode to debug
if not is_mode("release") and not is_mode("debug") then
    set_config("mode", "debug")
end

add_requires("boost", {configs = {components = "asio"}})

target("client")
    add_packages("boost")
    add_files("client.cpp")
client.cpp ```cpp #include #include int main(int argc, char *argv[]) { boost::asio::io_context io_ctx; boost::asio::signal_set signals(io_ctx, SIGINT, SIGTERM); signals.async_wait([&io_ctx](auto, auto){ io_ctx.stop(); }); boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 2001); boost::asio::ip::tcp::socket sock(io_ctx); sock.async_connect(ep, [&sock](const boost::system::error_code &ec){ if(ec) { std::cerr << "Error during connection: " << ec.message() << std::endl; return; } boost::asio::async_write(sock, boost::asio::buffer("Request here"), [](const boost::system::error_code &ec, std::size_t bytes_transferred){ if(ec) { std::cerr << "Error during sending request: " << ec.message() << std::endl; return; } std::cout << "Request sent" << std::endl; }); }); io_ctx.run(); return 0; } ```

Additional Information and Error Logs

xmake f -p mingw -vD ```bash > xmake f -p mingw -vD checking for architecture ... x86_64 checking for mingw directory ... C:\Program Files\mydevtools\MinGW-w64 checkinfo: cannot runv(unzip.exe -v), No such file or directory checking for unzip ... no checking for 7z ... C:\Program Files\mydevtools\xmake\winenv\bin\7z checking for git ... ok checkinfo: cannot runv(gzip.exe --version), No such file or directory checking for gzip ... no checking for ping ... ok pinging the host(gitlab.com) ... 10 ms pinging the host(github.com) ... 25 ms pinging the host(gitee.com) ... 258 ms updating repositories .. cloning repository(build-artifacts): https://gitlab.com/xmake-mirror/build-artifacts.git to C:\Users\Y\AppData\Local\.xmake\repositories\build-artifacts .. git clone https://gitlab.com/xmake-mirror/build-artifacts.git -b main -c core.fsmonitor=false C:\Users\Y\AppData\Local\.xmake\repositories\build-artifacts Cloning into 'C:\Users\Y\AppData\Local\.xmake\repositories\build-artifacts'... remote: Enumerating objects: 12407, done. remote: Counting objects: 100% (756/756), done. remote: Compressing objects: 100% (593/593), done. remote: Total 12407 (delta 390), reused 0 (delta 0), pack-reused 11651 Receiving objects: 100% (12407/12407), 2.56 MiB | 7.79 MiB/s, done. Resolving deltas: 100% (6457/6457), done. cloning repository(xmake-repo): https://gitlab.com/tboox/xmake-repo.git to C:\Users\Y\AppData\Local\.xmake\repositories\xmake-repo .. git clone https://gitlab.com/tboox/xmake-repo.git -b master -c core.fsmonitor=false C:\Users\Y\AppData\Local\.xmake\repositories\xmake-repo Cloning into 'C:\Users\Y\AppData\Local\.xmake\repositories\xmake-repo'... remote: Enumerating objects: 26711, done. remote: Counting objects: 100% (798/798), done. remote: Compressing objects: 100% (654/654), done. remote: Total 26711 (delta 352), reused 0 (delta 0), pack-reused 25913 Receiving objects: 100% (26711/26711), 4.98 MiB | 11.09 MiB/s, done. Resolving deltas: 100% (15286/15286), done. ok git rev-parse HEAD finding boost from xmake .. checking for xmake::boost ... no finding boost from vcpkg .. finding boost from conan .. checking for boost ... no note: install or modify (m) these packages (pass -y to skip confirm)? in xmake-repo: -> boost 1.84.0 [components:"asio"] please input: y (y/n/m) y checking for curl ... C:\Program Files\mydevtools\xmake\winenv\bin\curl C:\Program Files\mydevtools\xmake\winenv\bin\curl -SL -A "Xmake/2.8.6+HEAD.211710b67 (Windows;) curl/8.2.1" https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz -o boost-1.84.0.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 118M 100 118M 0 0 31.3M 0 0:00:03 0:00:03 --:--:-- 40.5M C:\Program Files\mydevtools\xmake\winenv\bin\7z x -y boost-1.84.0.tar.gz -oC:\Users\Y\AppData\Local\Temp\.xmake\240219\_17BF377ED3F14B508C86EF89206F4B50.tar 7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21 Scanning the drive for archives: 1 file, 123792694 bytes (119 MiB) Extracting archive: boost-1.84.0.tar.gz -- Path = boost-1.84.0.tar.gz Type = gzip Headers Size = 10 Everything is Ok Size: 555141120 Compressed: 123792694 C:\Program Files\mydevtools\xmake\winenv\bin\7z x -y C:\Users\Y\AppData\Local\Temp\.xmake\240219\_17BF377ED3F14B508C86EF89206F4B50.tar\boost-1.84.0.tar -osource.tmp 7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21 Scanning the drive for archives: 1 file, 555141120 bytes (530 MiB) Extracting archive: C:\Users\Y\AppData\Local\Temp\.xmake\240219\_17BF377ED3F14B508C86EF89206F4B50.tar\boost-1.84.0.tar -- Path = C:\Users\Y\AppData\Local\Temp\.xmake\240219\_17BF377ED3F14B508C86EF89206F4B50.tar\boost-1.84.0.tar Type = tar Physical Size = 555141120 Headers Size = 32190976 Code Page = UTF-8 Everything is Ok Folders: 5338 Files: 55706 Size: 508382688 Compressed: 555141120 => download https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz .. ok checking for x86_64-w64-mingw32-g++ ... C:\Program Files\mydevtools\MinGW-w64\bin\x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ bootstrap.bat gcc Building Boost.Build engine ### ### Using 'gcc' toolset. ### C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\source\tools\build\src\engine>"g++" -x c++ -std=c++11 -s -O3 -o b2.exe -D_GNU_SOURCE -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filent.cpp filesys.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp jam_strings.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\source\tools\build\src\engine>dir *.exe Volume in drive C has no label. Volume Serial Number is 44B7-95EB Directory of C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\source\tools\build\src\engine 19-Feb-24 01:01 388 096 b2.exe 1 File(s) 388 096 bytes 0 Dir(s) 614 747 131 904 bytes free Generating Boost.Build configuration in project-config.jam for gcc... Bootstrapping is done. To build, run: .\b2 To generate header files, run: .\b2 headers To adjust configuration, edit 'project-config.jam'. Further information: - Command line help: .\b2 --help - Getting started guide: http://boost.org/more/getting_started/windows.html - Boost.Build documentation: http://www.boost.org/build/ ./b2 headers warning: No toolsets are configured. warning: Configuring default toolset "msvc". warning: If the default is wrong, your build may not work correctly. warning: Use the "toolset=xxxxx" option to override our guess. warning: For more configuration options, please consult warning: https://www.bfgroup.xyz/b2/manual/release/index.html#bbv2.overview.configuration Performing configuration checks - default address-model : none [1] - default architecture : none [1] - symlinks supported : yes [1] msvc-14.3 ...found 1393 targets... ...updating 625 targets... mklink-or-dir boost mklink-or-dir boost\accumulators symbolic link created for boost\accumulators <<===>> ..\libs\accumulators\include\boost\accumulators mklink-or-dir boost\algorithm symbolic link created for boost\algorithm <<===>> ..\libs\algorithm\include\boost\algorithm mklink-or-dir boost\align symbolic link created for boost\align <<===>> ..\libs\align\include\boost\align link.mklink boost\align.hpp symbolic link created for boost\align.hpp <<===>> ..\libs\align\include\boost\align.hpp mklink-or-dir boost\any symbolic link created for boost\any <<===>> ..\libs\any\include\boost\any link.mklink boost\any.hpp symbolic link created for boost\any.hpp <<===>> ..\libs\any\include\boost\any.hpp link.mklink boost\array.hpp symbolic link created for boost\array.hpp <<===>> ..\libs\array\include\boost\array.hpp mklink-or-dir boost\asio symbolic link created for boost\asio <<===>> ..\libs\asio\include\boost\asio link.mklink boost\asio.hpp symbolic link created for boost\asio.hpp <<===>> ..\libs\asio\include\boost\asio.hpp mklink-or-dir boost\callable_traits symbolic link created for boost\callable_traits <<===>> ..\libs\callable_traits\include\boost\callable_traits link.mklink boost\mem_fn.hpp symbolic link created for boost\mem_fn.hpp <<===>> ..\libs\bind\include\boost\mem_fn.hpp link.mklink boost\callable_traits.hpp symbolic link created for boost\callable_traits.hpp <<===>> ..\libs\callable_traits\include\boost\callable_traits.hpp mklink-or-dir boost\chrono symbolic link created for boost\chrono <<===>> ..\libs\chrono\include\boost\chrono link.mklink boost\chrono.hpp symbolic link created for boost\chrono.hpp <<===>> ..\libs\chrono\include\boost\chrono.hpp mklink-or-dir boost\circular_buffer symbolic link created for boost\circular_buffer <<===>> ..\libs\circular_buffer\include\boost\circular_buffer link.mklink boost\circular_buffer.hpp symbolic link created for boost\circular_buffer.hpp <<===>> ..\libs\circular_buffer\include\boost\circular_buffer.hpp link.mklink boost\cobalt.hpp symbolic link created for boost\cobalt.hpp <<===>> ..\libs\cobalt\include\boost\cobalt.hpp mklink-or-dir boost\compat symbolic link created for boost\compat <<===>> ..\libs\compat\include\boost\compat mklink-or-dir boost\compatibility symbolic link created for boost\compatibility <<===>> ..\libs\compatibility\include\boost\compatibility mklink-or-dir boost\compute symbolic link created for boost\compute <<===>> ..\libs\compute\include\boost\compute link.mklink boost\compute.hpp symbolic link created for boost\compute.hpp <<===>> ..\libs\compute\include\boost\compute.hpp mklink-or-dir boost\concept symbolic link created for boost\concept <<===>> ..\libs\concept_check\include\boost\concept mklink-or-dir boost\concept_check symbolic link created for boost\concept_check <<===>> ..\libs\concept_check\include\boost\concept_check link.mklink boost\concept_check.hpp symbolic link created for boost\concept_check.hpp <<===>> ..\libs\concept_check\include\boost\concept_check.hpp link.mklink boost\concept_archetype.hpp symbolic link created for boost\concept_archetype.hpp <<===>> ..\libs\concept_check\include\boost\concept_archetype.hpp mklink-or-dir boost\config symbolic link created for boost\config <<===>> ..\libs\config\include\boost\config link.mklink boost\circular_buffer_fwd.hpp symbolic link created for boost\circular_buffer_fwd.hpp <<===>> ..\libs\circular_buffer\include\boost\circular_buffer_fwd.hpp link.mklink boost\config.hpp symbolic link created for boost\config.hpp <<===>> ..\libs\config\include\boost\config.hpp link.mklink boost\cstdint.hpp symbolic link created for boost\cstdint.hpp <<===>> ..\libs\config\include\boost\cstdint.hpp mklink-or-dir boost\detail link.mklink boost\cxx11_char_types.hpp symbolic link created for boost\cxx11_char_types.hpp <<===>> ..\libs\config\include\boost\cxx11_char_types.hpp link.mklink boost\limits.hpp symbolic link created for boost\limits.hpp <<===>> ..\libs\config\include\boost\limits.hpp mklink-or-dir boost\container ------------------------ cut the log to fit in the 65536 character limit ------------------------ symbolic link created for boost\container <<===>> ..\libs\container\include\boost\container mklink-or-dir boost\functional link.mklink boost\version.hpp symbolic link created for boost\version.hpp <<===>> ..\libs\config\include\boost\version.hpp mklink-or-dir boost\container_hash symbolic link created for boost\container_hash <<===>> ..\libs\container_hash\include\boost\container_hash link.mklink boost\detail\workaround.hpp symbolic link created for boost\detail\workaround.hpp <<===>> ..\..\libs\config\include\boost\detail\workaround.hpp mklink-or-dir boost\context symbolic link created for boost\context <<===>> ..\libs\context\include\boost\context link.mklink boost\detail\lightweight_test.hpp symbolic link created for boost\detail\lightweight_test.hpp <<===>> ..\..\libs\core\include\boost\detail\lightweight_test.hpp link.mklink boost\detail\no_exceptions_support.hpp symbolic link created for boost\detail\no_exceptions_support.hpp <<===>> ..\..\libs\core\include\boost\detail\no_exceptions_support.hpp link.mklink boost\detail\iterator.hpp symbolic link created for boost\detail\iterator.hpp <<===>> ..\..\libs\core\include\boost\detail\iterator.hpp mklink-or-dir boost\functional\hash symbolic link created for boost\functional\hash <<===>> ..\..\libs\container_hash\include\boost\functional\hash link.mklink boost\functional\hash.hpp symbolic link created for boost\functional\hash.hpp <<===>> ..\..\libs\container_hash\include\boost\functional\hash.hpp link.mklink boost\functional\factory.hpp symbolic link created for boost\functional\factory.hpp <<===>> ..\..\libs\functional\include\boost\functional\factory.hpp link.mklink boost\functional\forward_adapter.hpp symbolic link created for boost\functional\forward_adapter.hpp <<===>> ..\..\libs\functional\include\boost\functional\forward_adapter.hpp link.mklink boost\functional\identity.hpp symbolic link created for boost\functional\identity.hpp <<===>> ..\..\libs\functional\include\boost\functional\identity.hpp mklink-or-dir boost\functional\overloaded_function symbolic link created for boost\functional\overloaded_function <<===>> ..\..\libs\functional\include\boost\functional\overloaded_function link.mklink boost\functional\lightweight_forward_adapter.hpp symbolic link created for boost\functional\lightweight_forward_adapter.hpp <<===>> ..\..\libs\functional\include\boost\functional\lightweight_forward_adapter.hpp link.mklink boost\functional\hash_fwd.hpp symbolic link created for boost\functional\hash_fwd.hpp <<===>> ..\..\libs\container_hash\include\boost\functional\hash_fwd.hpp link.mklink boost\functional\overloaded_function.hpp symbolic link created for boost\functional\overloaded_function.hpp <<===>> ..\..\libs\functional\include\boost\functional\overloaded_function.hpp link.mklink boost\detail\scoped_enum_emulation.hpp symbolic link created for boost\variant.hpp <<===>> ..\libs\variant\include\boost\variant.hpp link.mklink boost\type_traits.hpp symbolic link created for boost\type_traits.hpp <<===>> ..\libs\type_traits\include\boost\type_traits.hpp mklink-or-dir boost\units symbolic link created for boost\units <<===>> ..\libs\units\include\boost\units link.mklink boost\metaparse.hpp symbolic link created for boost\metaparse.hpp <<===>> ..\libs\metaparse\include\boost\metaparse.hpp mklink-or-dir boost\optional symbolic link created for boost\optional <<===>> ..\libs\optional\include\boost\optional link.mklink boost\optional.hpp symbolic link created for boost\optional.hpp <<===>> ..\libs\optional\include\boost\optional.hpp mklink-or-dir boost\multi_array symbolic link created for boost\multi_array <<===>> ..\libs\multi_array\include\boost\multi_array link.mklink boost\multi_array.hpp symbolic link created for boost\multi_array.hpp <<===>> ..\libs\multi_array\include\boost\multi_array.hpp mklink-or-dir boost\beast symbolic link created for boost\beast <<===>> ..\libs\beast\include\boost\beast mklink-or-dir boost\vmd symbolic link created for boost\vmd <<===>> ..\libs\vmd\include\boost\vmd link.mklink boost\beast.hpp symbolic link created for boost\beast.hpp <<===>> ..\libs\beast\include\boost\beast.hpp mklink-or-dir boost\bimap symbolic link created for boost\bimap <<===>> ..\libs\bimap\include\boost\bimap link.mklink boost\bimap.hpp symbolic link created for boost\bimap.hpp <<===>> ..\libs\bimap\include\boost\bimap.hpp mklink-or-dir boost\bind symbolic link created for boost\bind <<===>> ..\libs\bind\include\boost\bind link.mklink boost\bind.hpp symbolic link created for boost\bind.hpp <<===>> ..\libs\bind\include\boost\bind.hpp link.mklink boost\is_placeholder.hpp symbolic link created for boost\is_placeholder.hpp <<===>> ..\libs\bind\include\boost\is_placeholder.hpp mklink-or-dir boost\wave symbolic link created for boost\wave <<===>> ..\libs\wave\include\boost\wave link.mklink boost\variant2.hpp symbolic link created for boost\variant2.hpp <<===>> ..\libs\variant2\include\boost\variant2.hpp mklink-or-dir boost\winapi symbolic link created for boost\winapi <<===>> ..\libs\winapi\include\boost\winapi mklink-or-dir boost\xpressive symbolic link created for boost\xpressive <<===>> ..\libs\xpressive\include\boost\xpressive link.mklink boost\wave.hpp symbolic link created for boost\wave.hpp <<===>> ..\libs\wave\include\boost\wave.hpp mklink-or-dir boost\yap symbolic link created for boost\yap <<===>> ..\libs\yap\include\boost\yap link.mklink boost\cast.hpp symbolic link created for boost\cast.hpp <<===>> ..\libs\numeric\conversion\include\boost\cast.hpp mklink-or-dir boost\numeric mklink-or-dir boost\numeric\conversion symbolic link created for boost\numeric\conversion <<===>> ..\..\libs\numeric\conversion\include\boost\numeric\conversion mklink-or-dir boost\numeric\interval symbolic link created for boost\numeric\interval <<===>> ..\..\libs\numeric\interval\include\boost\numeric\interval mklink-or-dir boost\numeric\odeint symbolic link created for boost\numeric\odeint <<===>> ..\..\libs\numeric\odeint\include\boost\numeric\odeint mklink-or-dir boost\numeric\ublas symbolic link created for boost\numeric\ublas <<===>> ..\..\libs\numeric\ublas\include\boost\numeric\ublas link.mklink boost\numeric\interval.hpp symbolic link created for boost\numeric\interval.hpp <<===>> ..\..\libs\numeric\interval\include\boost\numeric\interval.hpp link.mklink boost\numeric\odeint.hpp symbolic link created for boost\numeric\odeint.hpp <<===>> ..\..\libs\numeric\odeint\include\boost\numeric\odeint.hpp ...updated 625 targets... error: ...xmake\repositories\xmake-repo\packages\b\boost\xmake.lua:320: boost build failed, please check log in C:\Users\Y\AppData\Local\.xmake\cache\packages\2402\b\boost\1.84.0\source\boost-log.txt stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:949]: [...xmake\repositories\xmake-repo\packages\b\boost\xmake.lua:320]: in function 'script' [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call' [...\modules\private\action\require\impl\actions\install.lua:369]: => install boost 1.84.0 .. failed error: @programdir\core\main.lua:314: @programdir\modules\async\runjobs.lua:320: ...\modules\private\action\require\impl\actions\install.lua:474: install failed! stack traceback: [C]: in function 'error' [@programdir\core\base\os.lua:949]: [...\modules\private\action\require\impl\actions\install.lua:474]: in function 'catch' [@programdir\core\sandbox\modules\try.lua:123]: in function 'try' [...\modules\private\action\require\impl\actions\install.lua:333]: [...modules\private\action\require\impl\install_packages.lua:479]: in function 'jobfunc' [@programdir\modules\async\runjobs.lua:237]: stack traceback: [C]: in function 'error' @programdir\core\base\os.lua:949: in function 'base/os.raiselevel' (...tail calls...) @programdir\core\main.lua:314: in upvalue 'cotask' @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397> ```
waruqi commented 8 months ago

you can improve this package to handle spaces. https://github.com/xmake-io/xmake-repo/blob/1a471e4f034c39f1027b3cb6e37522fac88ccddb/packages/b/boost/xmake.lua#L174