Skip to content

Commit 42ab460

Browse files
committed
Only include -fno-plt if the compiler supports it
1 parent 6712169 commit 42ab460

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ def init_env(
500500
env_cflags = shlex.split(os.environ.get('CFLAGS', ''))
501501
env_cppflags = shlex.split(os.environ.get('CPPFLAGS', ''))
502502
env_ldflags = shlex.split(os.environ.get('LDFLAGS', ''))
503+
# Newer clang does not use -fno-plt leading to an error
504+
no_plt = '-fno-plt' if test_compile(cc, '-fno-plt', '-Werror') else ''
503505

504506
cflags_ = os.environ.get(
505507
'OVERRIDE_CFLAGS', (
506508
f'-Wextra {float_conversion} -Wno-missing-field-initializers -Wall -Wstrict-prototypes {std}'
507509
f' {werror} {optimize} {sanitize_flag} -fwrapv {stack_protector} {missing_braces}'
508-
f' -pipe -fvisibility=hidden -fno-plt'
510+
f' -pipe -fvisibility=hidden {no_plt}'
509511
)
510512
)
511513
cflags = shlex.split(cflags_) + shlex.split(

0 commit comments

Comments
 (0)