Compilation issue on x86_64: relocation R_X86_64_TPOFF32 against `buffer' can not be used when making a shared object; recompile with -fPIC
I'm one of the distro maintainers for the Chromebrew project, and I'm having an issue compiling the latest tagged release (2.99.8) for x86_64:
meson configure lines are:
meson -Dprefix=/usr/local \
-Dlibdir=/usr/local/lib64 \
-Dmandir=/usr/local/share/man \
-Dbuildtype=release \
-Db_lto=true \
-Dstrip=true \
-Db_pie=true \
-Dcpp_args='-O3 -pipe' -Dc_args='-O3 -pipe' \
-Dtests=false \
-Dsysprof=disabled \
-Dintrospection=enabled \
-Ddefault_library=both \
builddir
When running ninja this is what the compile ends with:
The Meson build system
Version: 0.58.1
Source dir: /usr/local/tmp/crew/libsoup.20210622171932.dir
Build dir: /usr/local/tmp/crew/libsoup.20210622171932.dir/builddir
Build type: native build
Project name: libsoup
Project version: 2.99.8
C compiler for the host machine: cc (gcc 11.1.0 "cc (GCC) 11.1.0")
C linker for the host machine: cc ld.bfd 2.36.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wmissing-include-dirs: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Winit-self: YES
Compiler for C supports arguments -Werror=missing-prototypes: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES
Compiler for C supports arguments -Werror=aggregate-return: YES
Compiler for C supports arguments -Werror=format=2: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=incompatible-pointer-types: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wno-format-zero-length: YES
Compiler for C supports arguments -Wno-missing-include-dirs: YES
Compiler for C supports arguments -Wno-typedef-redefinition: NO
Compiler for C supports arguments -Wno-unused-parameter: YES
Compiler for C supports arguments -Wno-sign-compare: YES
Compiler for C supports arguments -Wno-cast-function-type: YES
Compiler for C supports arguments -Wno-missing-field-initializers: YES
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Run-time dependency glib-2.0 found: YES 2.68.2
Run-time dependency gobject-2.0 found: YES 2.68.2
Run-time dependency gio-2.0 found: YES 2.68.2
Run-time dependency libnghttp2 found: YES 1.43.0
Run-time dependency sqlite3 found: YES 3.33.0
Run-time dependency libxml-2.0 found: YES 2.9.12
Run-time dependency libbrotlidec found: YES 1.0.9
Run-time dependency gio-unix-2.0 found: YES 2.68.2
Run-time dependency libpsl found: YES 0.21.1
Checking for function "gmtime_r" : YES
Dependency sysprof-capture-4 skipped: feature sysprof disabled
Checking if "GIO has real TLS support" with dependencies glib-2.0, gobject-2.0, gio-2.0 runs: YES
Run-time dependency zlib found: YES 1.2.11
Program apachectl /sbin/apachectl /usr/sbin/apachectl found: NO
Program httpd2 httpd apache2 apache /sbin/httpd2 /sbin/httpd /sbin/apache2 /sbin/apache /usr/sbin/httpd2 /usr/sbin/httpd /usr/sbin/apache2 /usr/sbin/apache found: NO
Program python3 found: YES (/usr/local/bin/python3)
Message: Python module quart found: NO
Run-time dependency gnutls found: YES 3.7.2
meson.build:315: WARNING: Some regression tests will not be compiled due to missing libraries or modules. Please check the logs for more details.
Program krb5-config found: YES (/usr/local/bin/krb5-config)
Program ntlm_auth found: NO
Program g-ir-scanner found: YES (/usr/local/bin/g-ir-scanner)
Vala compiler for the host machine: valac (valac 0.51.2)
Configuring config.h using configuration
Program generate-version-header.py found: YES (/usr/local/tmp/crew/libsoup.20210622171932.dir/libsoup/generate-version-header.py)
Configuring soup-version.h with command
Program glib-mkenums found: YES (/usr/local/bin/glib-mkenums)
Program glib-mkenums found: YES (/usr/local/bin/glib-mkenums)
Program glib-mkenums found: YES (/usr/local/bin/glib-mkenums)
Found pkg-config: /usr/local/bin/pkg-config (0.29.2)
Build-time dependency gobject-introspection-1.0 found: YES 1.68.0
Dependency gobject-introspection-1.0 found: YES 1.68.0 (cached)
Program g-ir-scanner found: YES (/usr/local/bin/g-ir-scanner)
Dependency gobject-introspection-1.0 found: YES 1.68.0 (cached)
Program g-ir-compiler found: YES (/usr/local/bin/g-ir-compiler)
Program vapigen found: YES (/usr/local/bin/vapigen)
Program xgettext found: YES (/usr/local/bin/xgettext)
Compiler for C supports arguments -fsanitize=fuzzer,address,undefined: NO
Build targets in project: 18
libsoup 2.99.8
Directories
prefix : /usr/local
libdir : lib64
datadir : share
Features
GSSAPI : True
NTLM : False
Brotli : True
Translations : True
GIR : True
VAPI : True
Documentation : False
Testing
All tests : False
Tests requiring Apache: False
Tests requiring Quart : False
Fuzzing tests : False
Autobahn tests : False
PKCS #11 tests : True
Install tests : False
Unix sockets : True
Found ninja-1.10.2 at /usr/local/bin/ninja
Core properties:
Source dir /usr/local/tmp/crew/libsoup.20210622171932.dir
Build dir /usr/local/tmp/crew/libsoup.20210622171932.dir/builddir
Main project options:
Core options Current Value Possible Values Description
------------ ------------- --------------- -----------
auto_features auto [enabled, disabled, auto] Override value of all 'auto' features
backend ninja [ninja, vs, vs2010, vs2015, Backend to use
vs2017, vs2019, xcode]
buildtype release [plain, debug, debugoptimized, Build type to use
release, minsize, custom]
cmake_prefix_path [] List of additional prefixes for cmake to search
debug false [true, false] Debug
default_library both [shared, static, both] Default library type
force_fallback_for [] Force fallback for those subprojects
install_umask 0022 [preserve, 0000-0777] Default umask to apply on permissions of installed files
layout mirror [mirror, flat] Build directory layout
optimization 3 [0, g, 1, 2, 3, s] Optimization level
pkg_config_path [] List of additional paths for pkg-config to search
strip true [true, false] Strip targets on install
unity off [on, off, subprojects] Unity build
unity_size 4 >=2 Unity block size
warning_level 2 [0, 1, 2, 3] Compiler warning level to use
werror false [true, false] Treat warnings as errors
wrap_mode default [default, nofallback, Wrap mode
nodownload, forcefallback,
nopromote]
Backend options Current Value Possible Values Description
--------------- ------------- --------------- -----------
backend_max_links 0 >=0 Maximum number of linker processes to run or 0 for no limit
Base options Current Value Possible Values Description
------------ ------------- --------------- -----------
b_asneeded true [true, false] Use -Wl,--as-needed when linking
b_colorout always [auto, always, never] Use colored output
b_coverage false [true, false] Enable coverage tracking.
b_lto true [true, false] Use link time optimization
b_lto_threads 0 Use multiple threads for Link Time Optimization
b_lundef true [true, false] Use -Wl,--no-undefined when linking
b_ndebug false [true, false, if-release] Disable asserts
b_pch true [true, false] Use precompiled headers
b_pgo off [off, generate, use] Use profile guided optimization
b_pie true [true, false] Build executables as position independent
b_sanitize none [none, address, thread, Code sanitizer to use
undefined, memory,
address,undefined]
b_staticpic true [true, false] Build static libraries as position independent
Compiler options Current Value Possible Values Description
---------------- ------------- --------------- -----------
c_args [-O3, -pipe] Extra arguments passed to the c compiler
c_link_args [] Extra arguments passed to the c linker
c_std c99 [none, c89, c99, c11, c17, c18, C language standard to use
c2x, gnu89, gnu99, gnu11,
gnu17, gnu18, gnu2x]
vala_args [] Extra arguments passed to the vala compiler
vala_link_args [] Extra arguments passed to the vala linker
Directories Current Value Possible Values Description
----------- ------------- --------------- -----------
prefix /usr/local Installation prefix
bindir bin Executable directory
datadir share Data file directory
includedir include Header file directory
infodir share/info Info page directory
libdir lib64 Library directory
libexecdir libexec Library executable directory
localedir share/locale Locale data directory
localstatedir /var/local Localstate data directory
mandir share/man Manual page directory
sbindir sbin System executable directory
sharedstatedir /var/local/lib Architecture-independent data directory
sysconfdir etc Sysconf data directory
Testing options Current Value Possible Values Description
--------------- ------------- --------------- -----------
errorlogs true [true, false] Whether to print the logs from failing tests
stdsplit true [true, false] Split stdout and stderr in test logs
Project options Current Value Possible Values Description
--------------- ------------- --------------- -----------
autobahn auto [enabled, disabled, auto] Enable autobahn test suite
brotli auto [enabled, disabled, auto] Build with Brotli decompression support
fuzzing disabled [enabled, disabled, auto] enable fuzzing support
gssapi auto [enabled, disabled, auto] Build with GSSAPI support
gtk_doc false [true, false] Enable generating the API reference
http2_tests auto [enabled, disabled, auto] enable HTTP/2 tests depending on quart
installed_tests false [true, false] Install tests for as-installed testing
introspection enabled [enabled, disabled, auto] Build GObject Introspection data
krb5_config Where to look for krb5-config, path points to krb5-config
installation (defaultly looking in PATH)
ntlm auto [enabled, disabled, auto] Build with NTLM support
ntlm_auth ntlm_auth Where to look for ntlm_auth, path points to ntlm_auth
installation (defaultly looking in PATH)
pkcs11_tests auto [enabled, disabled, auto] enable PKCS #11 tests depending on gnutls
sysprof disabled [enabled, disabled, auto] enable sysprof-capture support for profiling
tests false [true, false] Enable unit tests compilation
tls_check true [true, false] Enable TLS support through glib-networking. If you are building
a package, you can disable this to allow building libsoup anyway
(since glib-networking is not actually required at compile
time), but you should be sure to add a runtime dependency on it.
vapi auto [enabled, disabled, auto] Build Vala bindings
ninja: Entering directory `builddir'
[1/169] Generating soup-private-enum-types.h with a custom command (wrapped by meson because command contains newlines, to capture output)
<snip>
[160/169] Linking target libsoup/libsoup-3.0.so.0.0.0
FAILED: libsoup/libsoup-3.0.so.0.0.0
cc -o libsoup/libsoup-3.0.so.0.0.0 libsoup/libsoup-3.0.so.0.0.0.p/meson-generated_.._soup-private-enum-types.c.o libsoup/libsoup-3.0.so.0.0.0.p/meson-generated_.._soup-enum-types.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth-basic.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth-digest.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth-ntlm.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth-negotiate.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-auth-manager.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-connection-auth.c.o libsoup/libsoup-3.0.so.0.0.0.p/auth_soup-tls-interaction.c.o libsoup/libsoup-3.0.so.0.0.0.p/cache_soup-cache.c.o libsoup/libsoup-3.0.so.0.0.0.p/cache_soup-cache-client-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/cache_soup-cache-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-decoder_soup-content-decoder.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-decoder_soup-content-processor.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-decoder_soup-converter-wrapper.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-sniffer_soup-content-sniffer.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-sniffer_soup-content-sniffer-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/cookies_soup-cookie.c.o libsoup/libsoup-3.0.so.0.0.0.p/cookies_soup-cookie-jar.c.o libsoup/libsoup-3.0.so.0.0.0.p/cookies_soup-cookie-jar-db.c.o libsoup/libsoup-3.0.so.0.0.0.p/cookies_soup-cookie-jar-text.c.o libsoup/libsoup-3.0.so.0.0.0.p/hsts_soup-hsts-enforcer.c.o libsoup/libsoup-3.0.so.0.0.0.p/hsts_soup-hsts-enforcer-db.c.o libsoup/libsoup-3.0.so.0.0.0.p/hsts_soup-hsts-policy.c.o libsoup/libsoup-3.0.so.0.0.0.p/http1_soup-client-message-io-http1.c.o libsoup/libsoup-3.0.so.0.0.0.p/http1_soup-body-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/http1_soup-body-output-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/http1_soup-message-io-data.c.o libsoup/libsoup-3.0.so.0.0.0.p/http1_soup-message-io-source.c.o libsoup/libsoup-3.0.so.0.0.0.p/http2_soup-client-message-io-http2.c.o libsoup/libsoup-3.0.so.0.0.0.p/http2_soup-body-input-stream-http2.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-auth-domain.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-auth-domain-basic.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-auth-domain-digest.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-message-body.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-path-map.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-server.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-server-io.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-server-message.c.o libsoup/libsoup-3.0.so.0.0.0.p/server_soup-socket.c.o libsoup/libsoup-3.0.so.0.0.0.p/websocket_soup-websocket.c.o libsoup/libsoup-3.0.so.0.0.0.p/websocket_soup-websocket-connection.c.o libsoup/libsoup-3.0.so.0.0.0.p/websocket_soup-websocket-extension.c.o libsoup/libsoup-3.0.so.0.0.0.p/websocket_soup-websocket-extension-deflate.c.o libsoup/libsoup-3.0.so.0.0.0.p/websocket_soup-websocket-extension-manager.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-client-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-client-message-io.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-connection.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-date-utils.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-filter-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-form.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-headers.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-header-names.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-init.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-io-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-logger.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-logger-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-message.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-message-headers.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-message-metrics.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-message-queue-item.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-method.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-misc.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-multipart.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-multipart-input-stream.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-session.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-session-feature.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-socket-properties.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-status.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-tld.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-uri-utils.c.o libsoup/libsoup-3.0.so.0.0.0.p/soup-version.c.o libsoup/libsoup-3.0.so.0.0.0.p/content-decoder_soup-brotli-decompressor.c.o -L/usr/local/lib64 -flto -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libsoup-3.0.so.0 -Wl,--enable-new-dtags -Wl,-rpath -Wl,/usr/local/lib64 -flto -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err /usr/local/lib64/libglib-2.0.so /usr/local/lib64/libgobject-2.0.so /usr/local/lib64/libgio-2.0.so /usr/local/lib64/libxml2.so /usr/local/lib64/libsqlite3.so /usr/local/lib64/libpsl.so -Wl,-rpath=/usr/local/lib64 /usr/local/lib64/libbrotlidec.so /usr/local/lib64/libz.so /usr/local/lib64/libnghttp2.so -Wl,--end-group
/usr/local/bin/ld: /usr/local/tmp/cczinkpb.ltrans7.ltrans.o: relocation R_X86_64_TPOFF32 against `buffer' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
I'm not seeing an issue with other architectures.
Is there something I am missing?