Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.4.3 causes relocation linker error on Android x86 #731

Closed
triplef opened this issue Sep 23, 2022 · 6 comments
Closed

v3.4.3 causes relocation linker error on Android x86 #731

triplef opened this issue Sep 23, 2022 · 6 comments

Comments

@triplef
Copy link
Contributor

triplef commented Sep 23, 2022

System Details

Cross-compiling to Android using clang from NDK 22.1.7171670

  • build system type... i386-apple-darwin21.6.0
  • host system type... i686-pc-linux-android
  • target system type... i686-pc-linux-android

Problems Description

After updating libffi from v3.4.2 to v3.4.3 we get the following linker error when linking another library against libffi on x86. The issue does not occur on armeabi-v7a, arm64-v8a, or x86_64.

 Linking library libgnustep-base ...
ld.lld: error: relocation R_386_PC32 cannot be used against symbol open_temp_exec_file; recompile with -fPIC
>>> defined in /build/x86/lib/libffi.a(closures.o)
>>> referenced by closures.c
>>>               closures.o:(dlmmap_locked) in archive /build/x86/lib/libffi.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Looking at the changes in v3.4.3 I saw that open_temp_exec_file() was made non-static in fc6b939.

There’s also the following warning in the build output, which wasn’t there with v3.4.2, but might be unrelated:

../src/tramp.c:262:22: warning: implicit declaration of function 'open_temp_exec_file' is invalid in C99 [-Wimplicit-function-declaration]
  tramp_globals.fd = open_temp_exec_file ();
                     ^
@atgreen
Copy link
Member

atgreen commented Sep 23, 2022 via email

@triplef
Copy link
Contributor Author

triplef commented Sep 23, 2022

Thanks Anthony, I appreciate it.

Adding Android to your CI would be great, I'll try to take a look. At least builds should be straightforward, but I haven't run tests this way yet.

@atgreen
Copy link
Member

atgreen commented Sep 24, 2022

Just building during CI testing would be an improvement, as evidenced by this issue. Thanks!

@triplef
Copy link
Contributor Author

triplef commented Sep 26, 2022

I added Android builds to CI in #732. However note that it doesn’t surface this issue as the library is only built, but not linked against.

@atgreen
Copy link
Member

atgreen commented Sep 26, 2022

Yea, I don't see this being reproduced: https://rl.gl/doc-text?id=RLGL-MM78U3DJ

@triplef
Copy link
Contributor Author

triplef commented Sep 27, 2022

Not sure why this isn’t surfacing on CI, but I fixed it by passing -fPIC in CFLAGS, as suggested by the error message.

Text relocations are generally not supported on Android, so maybe this is something that could be done in configure.

@triplef triplef closed this as completed Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants