diff options
author | L. E. Segovia <amy@centricular.com> | 2023-08-23 02:51:53 +0000 |
---|---|---|
committer | L. E. Segovia <amy@centricular.com> | 2023-11-21 19:19:47 -0300 |
commit | df6a972073a08dc004f8391532a0e572f1b616fa (patch) | |
tree | f12ef7f6cfabb7804fc66c170782fdf33a0764fd /config | |
parent | cce63e831e1e3e793f973046ba136ac11a199f5c (diff) |
gst-plugins-rs: Complete the NDK migration to fix linking against Rust
From !915 and !1191, the following bits were missing:
- Autotools expects the raw linker to perform detection for version
scripting. If that parameter isn't detected in the `--help`, shared
libraries are disabled (breaks libpng).
- Cargo, conversely, expects implicitly the clang executable itself
because of a new dependency on libunwind starting with 1.68
To appease both, I pass the corresponding linkers separately, then
massage the flags into link-args entries in the TOML's rustflags entry.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1255>
Diffstat (limited to 'config')
-rw-r--r-- | config/android.config | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/config/android.config b/config/android.config index 5b24585f..bdbc7dbb 100644 --- a/config/android.config +++ b/config/android.config @@ -104,6 +104,9 @@ env['CFLAGS'] = '' env['CXXFLAGS'] = '' env['OBJCFLAGS'] = '' +# Make sure user's env doesn't mess up with our build. +env.pop('RUSTFLAGS', None) + # Android NDK path env['ANDROID_NDK_HOME'] = toolchain_prefix @@ -152,7 +155,8 @@ if not target_arch in [Architecture.ARM64, Architecture.X86_64]: # nocopyreloc causes broken linking on arm64 ldflags += ' -Wl,-z,nocopyreloc ' -ldflags += f' -L{sysroot}/usr/lib/{host}/{v} ' +# Initialize both the linker and the sysroot +ldflags += f' -L{sysroot}/usr/lib/{host}/{v} -Wl,--sysroot={sysroot}' ldvariant = 'lld' ldflags += f' -fuse-ld={ldvariant} ' @@ -171,8 +175,11 @@ def llvm_cmd(command): env['CC']= ccache + llvm_cmd('clang') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' env['CC_FOR_BUILD']= ccache + llvm_cmd('clang') env['CXX']= ccache + llvm_cmd('clang++') + f' -target {llvm_triple}' + f' --sysroot {sysroot}' -# linker should be invoked through the clang/++ frontend -env['LD']= '' +# linker is needed for Autotools +env['LD']= llvm_cmd(f'ld.lld') +# Supply the linker separately to pick up the dependency on -lunwind +# See https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html +env['RUSTC_LINKER']= llvm_cmd(f'{llvm_triple}-clang') env['CPP']= llvm_cmd('clang') + ' -E' env['RANLIB']= llvm_cmd('llvm-ranlib') env['AR']= llvm_cmd('llvm-ar') |