added -fPIC flag

Signed-off-by: Pratik Mankawde <pmankawde@ripple.com>
This commit is contained in:
Pratik Mankawde
2025-11-12 16:58:01 +00:00
parent 1cc00cddd8
commit a93052e765
2 changed files with 17 additions and 16 deletions

View File

@@ -180,11 +180,12 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
# shared_linker_flags += '-static-libubsan -static-libasan -static-libtsan'
if architecture['platform'] == 'linux/amd64':
# Add -mcmodel=medium to both compiler AND linker flags
# Add -mcmodel=medium and -fPIC to both compiler AND linker flags
# This is needed because sanitizers create very large binaries
cxx_flags += ' -mcmodel=medium'
exe_linker_flags+='-mcmodel=medium'
shared_linker_flags += '-mcmodel=medium'
# -fPIC enables position independent code to avoid relocation range issues
cxx_flags += ' -mcmodel=medium -fPIC'
exe_linker_flags+='-mcmodel=medium -fPIC'
shared_linker_flags += '-mcmodel=medium -fPIC'
if "-O0" in cxx_flags:
cxx_flags = cxx_flags.replace("-O0", "-O1")

View File

@@ -12,29 +12,29 @@ tools.info.package_ids:confs+=["user.package:sanitizers"]
{% if sanitizers == "Address" %}
tools.build:cxxflags+=['-fsanitize=address,undefined,float-divide-by-zero,signed-integer-overflow
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -Wno-stringop-overflow -mcmodel=medium']
tools.build:sharedlinkflags+=['-mcmodel=medium']
tools.build:exelinkflags+=['-mcmodel=medium']
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -Wno-stringop-overflow -mcmodel=medium -fPIC']
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
{% elif sanitizers == "Thread" %}
tools.build:cxxflags+=['-fsanitize=thread,undefined,float-divide-by-zero,signed-integer-overflow -fno-omit-frame-pointer
-fno-var-tracking-assignments
-O1 -Wno-stringop-overflow -Wno-tsan -mcmodel=medium']
tools.build:sharedlinkflags+=['-mcmodel=medium']
tools.build:exelinkflags+=['-mcmodel=medium']
-O1 -Wno-stringop-overflow -Wno-tsan -mcmodel=medium -fPIC']
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
{% endif %}
{% elif compiler == "clang" %}
{% if sanitizers == "Address" %}
tools.build:cxxflags+=['-fsanitize=address,undefined,float-divide-by-zero,signed-integer-overflow,unsigned-integer-overflow
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium']
tools.build:sharedlinkflags+=['-mcmodel=medium']
tools.build:exelinkflags+=['-mcmodel=medium']
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium -fPIC']
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
{% elif sanitizers == "Thread" %}
tools.build:cxxflags+=['-fsanitize=thread,undefined,float-divide-by-zero,signed-integer-overflow,unsigned-integer-overflow
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium']
tools.build:sharedlinkflags+=['-mcmodel=medium']
tools.build:exelinkflags+=['-mcmodel=medium']
-fno-omit-frame-pointer -fno-var-tracking-assignments -O1 -mcmodel=medium -fPIC']
tools.build:sharedlinkflags+=['-mcmodel=medium -fPIC']
tools.build:exelinkflags+=['-mcmodel=medium -fPIC']
{% endif %}
{% endif %}