Skip to content

Commit 6e0a2bb

Browse files
committed
build: harmonize Clang checks
- Set the clang variable in `config.gypi` so it depends on compiler checks made by the configure script. - Replace gyp conditions with `llvm_version` and "0.0" with conditions that use the `clang` variable. - Always use `clang==1` or `clang==0` in gyp conditions PR-URL: #52873 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
1 parent 82d1c36 commit 6e0a2bb

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

common.gypi

+3-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
'v8_base': '<(PRODUCT_DIR)/obj.target/tools/v8_gypfiles/libv8_snapshot.a',
108108
}],
109109
['OS=="mac"', {
110-
'clang%': 1,
111110
'obj_dir%': '<(PRODUCT_DIR)/obj.target',
112111
'v8_base': '<(PRODUCT_DIR)/libv8_snapshot.a',
113112
}],
@@ -183,10 +182,10 @@
183182
}, {
184183
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
185184
}],
186-
['llvm_version=="0.0"', {
187-
'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
188-
}, {
185+
['clang==1', {
189186
'lto': ' -flto ', # Clang
187+
}, {
188+
'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
190189
}],
191190
],
192191
},

configure.py

+2
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,7 @@ def get_gas_version(cc):
10971097
# quite prepared to go that far yet.
10981098
def check_compiler(o):
10991099
if sys.platform == 'win32':
1100+
o['variables']['clang'] = 0
11001101
o['variables']['llvm_version'] = '0.0'
11011102
if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
11021103
nasm_version = get_nasm_version('nasm')
@@ -1106,6 +1107,7 @@ def check_compiler(o):
11061107
return
11071108

11081109
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
1110+
o['variables']['clang'] = B(is_clang)
11091111
version_str = ".".join(map(str, clang_version if is_clang else gcc_version))
11101112
print_verbose(f"Detected {'clang ' if is_clang else ''}C++ compiler (CXX={CXX}) version: {version_str}")
11111113
if not ok:

deps/openssl/openssl_common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
'TERMIOS',
6868
],
6969
'conditions': [
70-
[ 'llvm_version=="0.0"', {
70+
[ 'clang==0', {
7171
'cflags': ['-Wno-old-style-declaration',],
7272
}],
7373
],

deps/zlib/zlib.gyp

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'ZLIB_ROOT': '.',
88
'use_system_zlib%': 0,
99
'arm_fpu%': '',
10-
'llvm_version%': '0.0',
1110
},
1211
'conditions': [
1312
['use_system_zlib==0', {
@@ -24,7 +23,7 @@
2423
},{
2524
'defines': [ 'X86_NOT_WINDOWS' ],
2625
}],
27-
['OS!="win" or llvm_version!="0.0"', {
26+
['OS!="win" or clang==1', {
2827
'cflags': [ '-mssse3' ],
2928
'xcode_settings': {
3029
'OTHER_CFLAGS': [ '-mssse3' ],
@@ -65,7 +64,7 @@
6564
'conditions': [
6665
['OS!="ios"', {
6766
'conditions': [
68-
['OS!="win" and llvm_version=="0.0"', {
67+
['OS!="win" and clang==0', {
6968
'cflags': [ '-march=armv8-a+aes+crc' ],
7069
}],
7170
['OS=="android"', {
@@ -111,7 +110,7 @@
111110
# 'target_name': 'zlib_crc32_simd',
112111
# 'type': 'static_library',
113112
# 'conditions': [
114-
# ['OS!="win" or llvm_version!="0.0"', {
113+
# ['OS!="win" or clang==1', {
115114
# 'cflags': [
116115
# '-msse4.2',
117116
# '-mpclmul',

node.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@
488488
'-Wl,-bnoerrmsg',
489489
],
490490
}],
491-
['OS == "linux" and llvm_version != "0.0"', {
491+
['OS=="linux" and clang==1', {
492492
'libraries': ['-latomic'],
493493
}],
494494
],

tools/v8_gypfiles/toolchain.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
'<(V8_ROOT)/include',
135135
],
136136
'conditions': [
137-
['clang', {
137+
['clang==1', {
138138
'cflags': [ '-Werror', '-Wno-unknown-pragmas' ],
139139
},{
140140
'cflags!': [ '-Wall', '-Wextra' ],

tools/v8_gypfiles/v8.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@
17461746
['enable_lto=="true"', {
17471747
'cflags_cc': [ '-fno-lto' ],
17481748
}],
1749-
['clang or OS!="win"', {
1749+
['clang==1 or OS!="win"', {
17501750
'conditions': [
17511751
['_toolset == "host" and host_arch == "x64" or _toolset == "target" and target_arch=="x64"', {
17521752
'sources': [

0 commit comments

Comments
 (0)