mirror of
https://github.com/systemd/systemd.git
synced 2026-11-07 13:57:10 +00:00
meson: use -static-pie instead of -static in PIE mode
If compiling with -Db_pie=true, we should do PIE compilation (position
independent executables), even in the static mode.
The caveat is that people distributions actually override compilation
flags when doing their builds. They'll need to set the static flags
properly if they do such builds.
(cherry picked from commit 8b289a8c4d)
This commit is contained in:
1 parent
b7ae93f093
commit
dfdcaaa269
2 files changed
+14
-4
No files matched your search
+2
-3
@@ -1028,9 +1028,8 @@ libm = cc.find_library('m')
|
||||
# On some architectures, libatomic is required. But on some installations,
|
||||
# it is found, but actual linking fails. So let's try to use it opportunistically.
|
||||
# If it is installed, but not needed, it will be dropped because of --as-needed.
|
||||
if cc.links('''int main(int argc, char **argv) { return 0; }''',
|
||||
args : '-latomic',
|
||||
name : 'libatomic')
|
||||
basic_c_prog = '''int main(int argc, char **argv) { return 0; }'''
|
||||
if cc.links(basic_c_prog, args : '-latomic', name : 'libatomic')
|
||||
libatomic = declare_dependency(link_args : '-latomic')
|
||||
else
|
||||
libatomic = []
|
||||
|
||||
+12
-1
@@ -219,13 +219,24 @@ if conf.get('SYSTEMD_MULTICALL_BINARY') == 1
|
||||
]
|
||||
endif
|
||||
|
||||
if get_option('build-static')
|
||||
if (get_option('b_pie') and
|
||||
cc.links(basic_c_prog, args : '-static-pie', name : '-static-pie'))
|
||||
systemd_link_args = ['-static-pie', '-Wl,-static,-pie']
|
||||
else
|
||||
systemd_link_args = ['-static']
|
||||
endif
|
||||
else
|
||||
systemd_link_args = []
|
||||
endif
|
||||
|
||||
executables += [
|
||||
libexec_template + {
|
||||
'name' : 'systemd',
|
||||
'dbus' : true,
|
||||
'public' : true,
|
||||
'sources' : systemd_sources,
|
||||
'link_args_static' : get_option('build-static') ? ['-static'] : [],
|
||||
'link_args_static' : systemd_link_args,
|
||||
'link_with' : [
|
||||
libcore,
|
||||
libshared,
|
||||
|
||||
Reference in new issue
Block a user