| 1 |
From: Aryan Karamtoth <[email protected]> |
| 2 |
Date: Fri, 5 Jun 2026 15:54:20 -0300 |
| 3 |
Subject: Add hack to allow build in Debian |
| 4 |
|
| 5 |
Forwarded: not-needed |
| 6 |
Last-Update: 2026-02-18 |
| 7 |
|
| 8 |
This patch change the place where meson should looks for the C headers. Also this |
| 9 |
patch hardcoded the path search the llvm-18 headers file. |
| 10 |
|
| 11 |
clang-extract (0.0~git20260127.e831f5b-1) UNRELEASED; urgency=medium |
| 12 |
|
| 13 |
* Initial release. (Closes: #1117623) |
| 14 |
--- |
| 15 |
meson.build | 62 ++++++++++--------------------------------------------------- |
| 16 |
1 file changed, 10 insertions(+), 52 deletions(-) |
| 17 |
|
| 18 |
diff --git a/meson.build b/meson.build |
| 19 |
index ea79eb4..e5021ee 100644 |
| 20 |
--- a/meson.build |
| 21 |
+++ b/meson.build |
| 22 |
@@ -28,8 +28,6 @@ add_project_arguments( |
| 23 |
], language: 'cpp' |
| 24 |
) |
| 25 |
|
| 26 |
-fs = import('fs') |
| 27 |
- |
| 28 |
# For debug builds, we want every debug info we can get plus addrsan. |
| 29 |
buildtype = get_option('buildtype') |
| 30 |
if buildtype == 'debug' or buildtype == 'debugoptimized' |
| 31 |
@@ -50,58 +48,28 @@ gcc = find_program('gcc', version : '>=7.5.0') |
| 32 |
# building with the correct headers, otherwise we run the risk of building |
| 33 |
# clang-extract with different headers than libLLVM |
| 34 |
gcc_install_dir = '' |
| 35 |
-build_dir_absolute_path = meson.build_root() |
| 36 |
-simple_program_file = configure_file(output: 'simple_program.c', input: 'simple_program.c.in', copy: true ) |
| 37 |
- |
| 38 |
-gcc_output = run_command(gcc.full_path(), '-fno-PIC', '-v', '-o', build_dir_absolute_path / 'simple_program.out', |
| 39 |
- build_dir_absolute_path / 'simple_program.c', check: true).stderr().strip().split('\n') |
| 40 |
+gcc_output = run_command(gcc.full_path(), '-print-search-dirs', check: true).stdout().strip().split('\n') |
| 41 |
foreach line : gcc_output |
| 42 |
- if line.contains('crtbegin.o') |
| 43 |
- ilines = line.strip().split(' ') |
| 44 |
- foreach iline : ilines |
| 45 |
- if iline.contains('crtbegin.o') |
| 46 |
- gcc_install_dir = fs.parent(iline) |
| 47 |
- break |
| 48 |
- endif |
| 49 |
- endforeach |
| 50 |
+ params = line.split(':') |
| 51 |
+ lhs = params.get(0) |
| 52 |
+ rhs = params.get(1, '') |
| 53 |
+ |
| 54 |
+ if lhs == 'install' |
| 55 |
+ gcc_install_dir = rhs.strip() |
| 56 |
+ break |
| 57 |
endif |
| 58 |
endforeach |
| 59 |
-if build_machine.system() == 'linux' |
| 60 |
- rm = find_program('rm') |
| 61 |
- run_command(rm.full_path(),'-f', build_dir_absolute_path / 'simple_program.out', check: false) |
| 62 |
-endif |
| 63 |
|
| 64 |
# Check if we got the gcc installation dir and add it to the project arguments. |
| 65 |
assert(gcc_install_dir != '', 'GCC headers dir not found. Check \'gcc -v\'') |
| 66 |
-add_project_arguments('--gcc-install-dir=' + gcc_install_dir, language: 'cpp') |
| 67 |
- |
| 68 |
-########## Dependency: additional clang includes ################ |
| 69 |
-llvm_config = find_program('llvm-config') |
| 70 |
-if llvm_config.found() |
| 71 |
- extra_args_line = run_command(llvm_config.full_path(), '--cxxflags').stdout().strip().split('\n')[0] |
| 72 |
- extra_args = extra_args_line.split(' -') |
| 73 |
- i = 0 |
| 74 |
- foreach arg : extra_args |
| 75 |
- targ = arg |
| 76 |
- if i > 0 |
| 77 |
- targ = '-' + arg |
| 78 |
- endif |
| 79 |
- if(not targ.startswith('-I')) |
| 80 |
- i += 1 |
| 81 |
- continue |
| 82 |
- endif |
| 83 |
- message('Adding extra compilation flag: ' + targ) |
| 84 |
- add_project_arguments(targ, language: 'cpp') |
| 85 |
- i += 1 |
| 86 |
- endforeach |
| 87 |
-endif |
| 88 |
+add_project_arguments('-I/usr/lib/llvm-18/include', language:'cpp') |
| 89 |
|
| 90 |
########## Dependency: clang libraries ################ |
| 91 |
llvm_libdir = dependency('llvm', version : '>=16').get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir') |
| 92 |
|
| 93 |
clang_dep = [] |
| 94 |
clang_dep += cpp.find_library('clang-cpp', dirs : llvm_libdir) |
| 95 |
-clang_dep += cpp.find_library('LLVM', dirs : llvm_libdir) |
| 96 |
+clang_dep += cpp.find_library('LLVM-18', dirs : llvm_libdir) |
| 97 |
############################# ######################### |
| 98 |
elf_dep = dependency('libelf') # libelf |
| 99 |
zlib_dep = dependency('zlib') |
| 100 |
@@ -114,23 +82,13 @@ incdir = include_directories('libcextract') |
| 101 |
executable('ce-inline', 'Inline.cpp', |
| 102 |
include_directories : incdir, |
| 103 |
install : true, |
| 104 |
- link_args : ['--gcc-install-dir=' + gcc_install_dir], |
| 105 |
link_with : libcextract_static, |
| 106 |
dependencies : [elf_dep, zlib_dep, zstd_dep] |
| 107 |
) |
| 108 |
|
| 109 |
-executable('ce-includetree', 'TreeDump.cpp', |
| 110 |
- include_directories : incdir, |
| 111 |
- install : true, |
| 112 |
- link_args : ['--gcc-install-dir=' + gcc_install_dir], |
| 113 |
- link_with : libcextract_static, |
| 114 |
- dependencies : [elf_dep, clang_dep, zlib_dep, zstd_dep] |
| 115 |
-) |
| 116 |
- |
| 117 |
executable('clang-extract', 'Main.cpp', |
| 118 |
include_directories : incdir, |
| 119 |
install : true, |
| 120 |
- link_args : ['--gcc-install-dir=' + gcc_install_dir], |
| 121 |
link_with : libcextract_static, |
| 122 |
dependencies : [elf_dep, clang_dep, zlib_dep, zstd_dep] |
| 123 |
) |