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] tools.build:compiler_executables won't work with Meson due to spaces in the compiler path #16212

Closed
ssrobins opened this issue May 7, 2024 · 5 comments · Fixed by #16307
Assignees
Labels
Milestone

Comments

@ssrobins
Copy link
Contributor

ssrobins commented May 7, 2024

Describe the bug

Recently, the freetype recipe changed to use Meson as the build system and it caused this build error on Windows:

FAILED: libfreetype.a.p/src_truetype_truetype.c.obj 
"C:/Program" "Files/Microsoft" "Visual" "Studio/2022/Enterprise/VC/Tools/MSVC/14.38.33130/bin/HostX64/x86/cl.exe" "-Ilibfreetype.a.p" "-I." "-I..\src" "-I..\src\include" "-IC:/Users/runneradmin/.conan2/p/b/zlibceaa49f551150/p/include" "-IC:/Users/runneradmin/.conan2/p/b/bzip23b2943a7e9b0c/p/include" "-IC:/Users/runneradmin/.conan2/p/b/libpn589e77be4088e/p/include" "-IC:/Users/runneradmin/.conan2/p/b/brotl9ee50595b7757/p/include" "-IC:/Users/runneradmin/.conan2/p/b/brotl9ee50595b7757/p/include/brotli" "-DNDEBUG" "/MT" "/nologo" "/showIncludes" "/utf-8" "/W2" "/O2" "/Gw" "-DFT_CONFIG_MODULES_H=<ftmodule.h>" "-DFT2_BUILD_LIBRARY=1" "-DFT_CONFIG_OPTIONS_H=<ftoption.h>" "-DDLL_EXPORT=1" "/Fdlibfreetype.a.p\src_truetype_truetype.c.pdb" /Folibfreetype.a.p/src_truetype_truetype.c.obj "/c" ../src/src/truetype/truetype.c
CreateProcess failed: The system cannot find the file specifieninja: fatal: ReadFile: The handle is invalid.

I've been using https://github.com/conan-io/cmake-conan and it generates a profile that includes the tools.build:compiler_executables setting. The path to cl.exe contains spaces and something in Conan or Meson doesn't seem to handle that.

How to reproduce it

Run this:
conan install --requires freetype/2.13.2#7934d59c447d72edcd56025dc60e1aeb --build=missing --profile:host=C:/Users/Steve/Code/stackblox/build_windows/conan_host_profile

where conan_host_profile contains:

[settings]
arch=x86
os=Windows
compiler=msvc
compiler.version=193
compiler.runtime=static
build_type=Release
[conf]
tools.build:compiler_executables={"c":"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe","cpp":"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe"}

When I run the same command on an older version of the freetype recipe that used CMake:
conan install --requires freetype/2.13.2#dfa3d504cae4a08d5c72113bd6f28498 --build=missing --profile:host=C:/Users/Steve/Code/stackblox/build_windows/conan_host_profile

It works fine.

@RubenRBS
Copy link
Member

RubenRBS commented May 7, 2024

Failing logs:

-------- Installing package freetype/2.13.2 (8 of 8) --------
freetype/2.13.2: Building from source
freetype/2.13.2: Package freetype/2.13.2:e2dd2460ca67f242643d688af7bf376368a8545a
freetype/2.13.2: Copying sources to build folder
freetype/2.13.2: Building your package in /root/.conan2/p/b/freet0f013239db364/b
freetype/2.13.2: Calling generate()
freetype/2.13.2: Generators folder: /root/.conan2/p/b/freet0f013239db364/b/build-release/conan
freetype/2.13.2: Generating aggregated env files
freetype/2.13.2: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
freetype/2.13.2: Calling build()
freetype/2.13.2: Apply patch (portability): meson: Use the standard dependency mechanism to find bzip2
freetype/2.13.2: Meson configure cmd: meson setup --native-file "/root/.conan2/p/b/freet0f013239db364/b/build-release/conan/conan_meson_native.ini" "/root/.conan2/p/b/freet0f013239db364/b/build-release" "/root/.conan2/p/b/freet0f013239db364/b/src" -Dprefix="/root/.conan2/p/b/freet0f013239db364/p"
freetype/2.13.2: RUN: meson setup --native-file "/root/.conan2/p/b/freet0f013239db364/b/build-release/conan/conan_meson_native.ini" "/root/.conan2/p/b/freet0f013239db364/b/build-release" "/root/.conan2/p/b/freet0f013239db364/b/src" -Dprefix="/root/.conan2/p/b/freet0f013239db364/p"
The Meson build system
Version: 1.3.2
Source dir: /root/.conan2/p/b/freet0f013239db364/b/src
Build dir: /root/.conan2/p/b/freet0f013239db364/b/build-release
Build type: native build
Project name: freetype2
Project version: 2.13.2

../src/meson.build:26:0: ERROR: Unknown compiler(s): [['/root/path', 'spaces/cc']]
The following exception(s) were encountered:
Running `/root/path spaces/cc --version` gave "[Errno 2] No such file or directory: '/root/path'"

A full log can be found at /root/.conan2/p/b/freet0f013239db364/b/build-release/meson-logs/meson-log.txt

freetype/2.13.2: ERROR: 
Package 'e2dd2460ca67f242643d688af7bf376368a8545a' build failed
freetype/2.13.2: WARN: Build folder /root/.conan2/p/b/freet0f013239db364/b/build-release
ERROR: freetype/2.13.2: Error in build() method, line 112
	meson.configure()
	ConanException: Error 1 while executing

@franramirez688
Copy link
Contributor

Hi @ssrobins

Thanks for reporting this! Yes, it's a bug.
I was wondering if you really need to define the tools.build:compiler_executables in this case. MesonToolchain calls the VCVars generator so I think it could be enough to define the MSVC compiler paths.

@memsharded
Copy link
Member

I was wondering if you really need to define the tools.build:compiler_executables in this case. MesonToolchain calls the VCVars generator so I think it could be enough to define the MSVC compiler paths.

Yes, in my experience, it is not necessary to define the compiler_executable to the full path to the cl.exe. In some cases it might be necessary just {"c": "cl.exe", "cpp": "cl.exe"}, but the full path shouldn't be needed. The reason is that the msft compiler doesn't really work if it doesn't fully activate the environment via vcvars and that already puts cl.exe in the path.

Can you please try to remove the full path @ssrobins and let us know?

@ssrobins
Copy link
Contributor Author

ssrobins commented May 9, 2024

I was wondering if you really need to define the tools.build:compiler_executables in this case. MesonToolchain calls the VCVars generator so I think it could be enough to define the MSVC compiler paths.

Yes, in my experience, it is not necessary to define the compiler_executable to the full path to the cl.exe. In some cases it might be necessary just {"c": "cl.exe", "cpp": "cl.exe"}, but the full path shouldn't be needed. The reason is that the msft compiler doesn't really work if it doesn't fully activate the environment via vcvars and that already puts cl.exe in the path.

Can you please try to remove the full path @ssrobins and let us know?

Yes, changing it to tools.build:compiler_executables={"c":"cl.exe","cpp":"cl.exe"} or completely removing tools.build:compiler_executables from the profile solves the problem.

This removes the full path from tools.build:compiler_executables:
conan-io/cmake-conan#640

@franramirez688 franramirez688 added this to the 2.4.0 milestone May 9, 2024
@memsharded
Copy link
Member

I am not sure this conan-io/cmake-conan#640 will be able to move forward, we can discuss it there.
But independent of that, we still need here a fix for Meson so it doesn't fail with spaces in path, that is the real fix for this issue (even if defining compiler_executables = {"c": "cl.exe"} is a viable workaround from the user side)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants