build: Use cc.links to check linker arguments

Instead of hard-coding linker flags for a specific operating system and
a specific compiler, we can should cc.links to test them, so they can be
used on more operating systems and compilers.
This commit is contained in:
Ting-Wei Lan
2018-04-22 21:42:03 +08:00
committed by Matthias Clasen
parent e882db2763
commit 48af688940

View File

@@ -284,8 +284,12 @@ endif
common_ldflags = []
if host_machine.system() == 'linux' and cc.get_id() == 'gcc'
common_ldflags += [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
if os_unix and not os_darwin
foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
if cc.links('int main () { return 0; }', name: ldflag, args: ldflag)
common_ldflags += [ ldflag ]
endif
endforeach
endif
# Maintain compatibility with autotools