From: Aryan Karamtoth Date: Fri, 5 Jun 2026 15:54:20 -0300 Subject: Add hack to allow build in Debian Forwarded: not-needed Last-Update: 2026-02-18 This patch change the place where meson should looks for the C headers. Also this patch hardcoded the path search the llvm-18 headers file. clang-extract (0.0~git20260127.e831f5b-1) UNRELEASED; urgency=medium * Initial release. (Closes: #1117623) --- meson.build | 62 ++++++++++--------------------------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/meson.build b/meson.build index ea79eb4..e5021ee 100644 --- a/meson.build +++ b/meson.build @@ -28,8 +28,6 @@ add_project_arguments( ], language: 'cpp' ) -fs = import('fs') - # For debug builds, we want every debug info we can get plus addrsan. buildtype = get_option('buildtype') if buildtype == 'debug' or buildtype == 'debugoptimized' @@ -50,58 +48,28 @@ gcc = find_program('gcc', version : '>=7.5.0') # building with the correct headers, otherwise we run the risk of building # clang-extract with different headers than libLLVM gcc_install_dir = '' -build_dir_absolute_path = meson.build_root() -simple_program_file = configure_file(output: 'simple_program.c', input: 'simple_program.c.in', copy: true ) - -gcc_output = run_command(gcc.full_path(), '-fno-PIC', '-v', '-o', build_dir_absolute_path / 'simple_program.out', - build_dir_absolute_path / 'simple_program.c', check: true).stderr().strip().split('\n') +gcc_output = run_command(gcc.full_path(), '-print-search-dirs', check: true).stdout().strip().split('\n') foreach line : gcc_output - if line.contains('crtbegin.o') - ilines = line.strip().split(' ') - foreach iline : ilines - if iline.contains('crtbegin.o') - gcc_install_dir = fs.parent(iline) - break - endif - endforeach + params = line.split(':') + lhs = params.get(0) + rhs = params.get(1, '') + + if lhs == 'install' + gcc_install_dir = rhs.strip() + break endif endforeach -if build_machine.system() == 'linux' - rm = find_program('rm') - run_command(rm.full_path(),'-f', build_dir_absolute_path / 'simple_program.out', check: false) -endif # Check if we got the gcc installation dir and add it to the project arguments. assert(gcc_install_dir != '', 'GCC headers dir not found. Check \'gcc -v\'') -add_project_arguments('--gcc-install-dir=' + gcc_install_dir, language: 'cpp') - -########## Dependency: additional clang includes ################ -llvm_config = find_program('llvm-config') -if llvm_config.found() - extra_args_line = run_command(llvm_config.full_path(), '--cxxflags').stdout().strip().split('\n')[0] - extra_args = extra_args_line.split(' -') - i = 0 - foreach arg : extra_args - targ = arg - if i > 0 - targ = '-' + arg - endif - if(not targ.startswith('-I')) - i += 1 - continue - endif - message('Adding extra compilation flag: ' + targ) - add_project_arguments(targ, language: 'cpp') - i += 1 - endforeach -endif +add_project_arguments('-I/usr/lib/llvm-18/include', language:'cpp') ########## Dependency: clang libraries ################ llvm_libdir = dependency('llvm', version : '>=16').get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') clang_dep = [] clang_dep += cpp.find_library('clang-cpp', dirs : llvm_libdir) -clang_dep += cpp.find_library('LLVM', dirs : llvm_libdir) +clang_dep += cpp.find_library('LLVM-18', dirs : llvm_libdir) ############################# ######################### elf_dep = dependency('libelf') # libelf zlib_dep = dependency('zlib') @@ -114,23 +82,13 @@ incdir = include_directories('libcextract') executable('ce-inline', 'Inline.cpp', include_directories : incdir, install : true, - link_args : ['--gcc-install-dir=' + gcc_install_dir], link_with : libcextract_static, dependencies : [elf_dep, zlib_dep, zstd_dep] ) -executable('ce-includetree', 'TreeDump.cpp', - include_directories : incdir, - install : true, - link_args : ['--gcc-install-dir=' + gcc_install_dir], - link_with : libcextract_static, - dependencies : [elf_dep, clang_dep, zlib_dep, zstd_dep] -) - executable('clang-extract', 'Main.cpp', include_directories : incdir, install : true, - link_args : ['--gcc-install-dir=' + gcc_install_dir], link_with : libcextract_static, dependencies : [elf_dep, clang_dep, zlib_dep, zstd_dep] )