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

Meson doesn't escape newlines when generating build.ninja #10890

Open
LAK132 opened this issue Oct 4, 2022 · 0 comments
Open

Meson doesn't escape newlines when generating build.ninja #10890

LAK132 opened this issue Oct 4, 2022 · 0 comments

Comments

@LAK132
Copy link

LAK132 commented Oct 4, 2022

Describe the bug
cmake custom command strings with newlines aren't escaped correctly when generating ninja build scripts.

while attempting to build llvm from source with meson:

cmake = import('cmake')

if get_option('buildtype') == 'debug'
	llvm_build_type = 'Debug'
elif get_option('buildtype') == 'release'
	llvm_build_type = 'Release'
elif get_option('buildtype') == 'debugoptimized'
	llvm_build_type = 'RelWithDebInfo'
elif get_option('buildtype') == 'minsize'
	llvm_build_type = 'MinSizeRel'
else
	error('unsupported build type')
endif

llvm_parallel_jobs = 8

llvm_opts = cmake.subproject_options()

llvm_opts.add_cmake_defines({
	'LLVM_PARALLEL_COMPILE_JOBS': llvm_parallel_jobs,
	'LLVM_PARALLEL_LINK_JOBS': llvm_parallel_jobs,
	'LLVM_TARGETS_TO_BUILD': 'host',
	'LLVM_ENABLE_PROJECTS': 'llvm;clang;compiler-rt',
	'CMAKE_BUILD_TYPE': llvm_build_type,
})

llvm_subprj = cmake.subproject('llvm', options: llvm_opts)

it appears that meson is tripping up on the following in AddLLVM.cmake:

    add_custom_command(OUTPUT ${native_export_file}
      COMMAND "${Python3_EXECUTABLE}" -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
        < ${export_file} > ${native_export_file}
      DEPENDS ${export_file}
      VERBATIM
      COMMENT "Creating export file for ${target_name}")

it ends up putting a literal newline into the build.ninja instead of an escaped newline:

#############################################
# Custom command for llvm\tools\lto\LTO.def

build llvm\tools\lto\LTO.def | ${cmake_ninja_workdir}llvm\tools\lto\LTO.def: CUSTOM_COMMAND D$:\Repos\lak-clean\subprojects\llvm\llvm\tools\lto\lto.exports
  COMMAND = cmd.exe /C "cd /D D:\Repos\lak-clean\build\subprojects\llvm\__CMake_build\llvm\tools\lto && C:\Users\lakri\AppData\Local\Programs\Python\Python310\python.exe -c "import sys" "print(''.join(['EXPORTS
']+sys.stdin.readlines(),))" < D:/Repos/lak-clean/subprojects/llvm/llvm/tools/lto/lto.exports > LTO.def"
  DESC = Creating export file for LTO
  restat = 1

which results in an error:

| CMake Error:
| Running

| 'C:/PROGRA~1/Meson/ninja.EXE' '-C' 'D:/Repos/lak-clean/build/subprojects/llvm/__CMake_build' '-t' 'recompact'

| failed with:

| ninja: error: build.ninja:41934: lexing error

Expected behavior
meson should escape newlines when generating ninja build script

system parameters

  • native build
  • windows 10
  • python 3.10
  • meson 0.63.2
  • ninja 1.11.0
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

1 participant