@@ -5,33 +5,24 @@ import("//llvm/version.gni")
5
5
# This build file is just enough to get check-clang to pass, it's missing
6
6
# several things from the CMake build:
7
7
# - a build target copying the Python bindings
8
- # - the GN linux build always builds without -fPIC (as if LLVM_ENABLE_PIC=OFF
9
- # in the CMake build), so libclang is always a static library on linux
10
8
# - the GN build doesn't have LIBCLANG_BUILD_STATIC
11
9
12
- libclang_target_type = " shared_library"
13
- if (host_os != " win" && host_os != " mac" ) {
14
- # ELF targets need -fPIC to build shared libs but they aren't on by default.
15
- # For now, make libclang a static lib there.
16
- libclang_target_type = " static_library"
17
- } else {
18
- action (" linker_script_to_exports" ) {
19
- script = " linker-script-to-export-list.py"
20
- inputs = [ " libclang.map" ]
21
- outputs = [ " $target_gen_dir /libclang.exports" ]
22
- args = [
23
- rebase_path (inputs [0 ], root_build_dir ),
24
- rebase_path (outputs [0 ], root_build_dir ),
25
- ]
26
- }
10
+ action (" linker_script_to_exports" ) {
11
+ script = " linker-script-to-export-list.py"
12
+ inputs = [ " libclang.map" ]
13
+ outputs = [ " $target_gen_dir /libclang.exports" ]
14
+ args = [
15
+ rebase_path (inputs [0 ], root_build_dir ),
16
+ rebase_path (outputs [0 ], root_build_dir ),
17
+ ]
18
+ }
27
19
28
- symbol_exports (" exports" ) {
29
- deps = [ " :linker_script_to_exports" ]
30
- exports_file = " $target_gen_dir /libclang.exports"
31
- }
20
+ symbol_exports (" exports" ) {
21
+ deps = [ " :linker_script_to_exports" ]
22
+ exports_file = " $target_gen_dir /libclang.exports"
32
23
}
33
24
34
- target ( libclang_target_type , " libclang" ) {
25
+ shared_library ( " libclang" ) {
35
26
configs += [ " //llvm/utils/gn/build:clang_code" ]
36
27
deps = [
37
28
" //clang/include/clang/Config" ,
@@ -48,14 +39,17 @@ target(libclang_target_type, "libclang") {
48
39
" //llvm/lib/Support" ,
49
40
" //llvm/lib/Target:TargetsToBuild" ,
50
41
]
42
+ if (current_os == " win" || current_os == " mac" ) {
43
+ deps += [ " :exports" ]
44
+ } else {
45
+ inputs = [ " libclang.map" ]
46
+ ldflags =
47
+ [ " -Wl,--version-script," + rebase_path (inputs [0 ], root_build_dir ) ]
48
+ }
51
49
if (clang_enable_arcmt ) {
52
50
deps += [ " //clang/lib/ARCMigrate" ]
53
51
}
54
52
55
- if (libclang_target_type == " shared_library" ) {
56
- deps += [ " :exports" ]
57
- }
58
-
59
53
defines = []
60
54
61
55
if (host_os == " win" ) {
0 commit comments