Skip to content

Commit 0834fb6

Browse files
authored
Explicitly specify the target triple for native clang test builds (#16561)
This should make it work regardless of what the default target triple of clang is.
1 parent e9f070c commit 0834fb6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tests/clang_native.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@
55

66
import logging
77
import os
8+
import platform
9+
import sys
810
from tools.shared import PIPE, run_process, CLANG_CC, CLANG_CXX
911
from tools.utils import MACOS, WINDOWS, path_from_root
1012

1113
logger = logging.getLogger('clang_native')
1214

1315

16+
def get_native_triple():
17+
arch = {
18+
'aarch64': 'arm64',
19+
'arm64': 'arm64',
20+
'x86_64': 'x86_64',
21+
'AMD64': 'x86_64',
22+
}[platform.machine()]
23+
OS = {
24+
'linux': 'linux',
25+
'darwin': 'darwin',
26+
'win32': 'windows-msvc',
27+
}[sys.platform]
28+
return f'{arch}-{OS}'
29+
30+
1431
# These extra args need to be passed to Clang when targeting a native host system executable
1532
def get_clang_native_args():
33+
triple = ['--target=' + get_native_triple()]
1634
if MACOS:
17-
return ['-isystem', path_from_root('system/include/libcxx')]
35+
return triple + ['-isystem', path_from_root('system/include/libcxx')]
1836
elif os.name == 'nt':
1937
# TODO: If Windows.h et al. are needed, will need to add something like '-isystemC:/Program
2038
# Files (x86)/Microsoft SDKs/Windows/v7.1A/Include'.
21-
return ['-DWIN32']
39+
return triple + ['-DWIN32']
2240
else:
23-
return []
41+
return triple
2442

2543

2644
# This environment needs to be present when targeting a native host system executable

0 commit comments

Comments
 (0)