-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ld.lld: error: relocation R_386_PC32 cannot be used against symbol __zig_probe_stack #7935
Comments
The LLVM's code emitting the stack-probe call defaults to cc @MaskRay |
I suspect zig sets dso_local on function declarations for -fpic mode. |
AFAICS not really, at least not explicitly. |
This problem can be reproduced with this small snippet of LLVM IR: target triple = "i386-unknown-linux-none"
declare void @ext()
define void @dummy() #0 {
Entry:
%trigger = alloca [4097 x i8], align 1
call void @ext()
ret void
}
attributes #0 = { "probe-stack"="probe" } When compiled with |
I have encountered this bug today when working on android-x86 |
This seems pretty critical. Pretty much disallows using Zig for building shared libraries. The suggested workaround isn't practical to use since there's no way to pass lld flags from build.zig, and even compiling in release doesn't always work. Here's a simple example that triggers this bug in ReleaseSafe mode: const std = @import("std");
export fn hello() void {
std.debug.print("Hello, world!\n", .{});
} Compile with |
Current
See pull request #10056 (and merged commit 2cdffc9). I've tested it with Both my example (from issue report) and yours (from quoted comment, with exactly the same command line arguments as you provided, except added I've updated my original report with this workaround. Still, I want to stress, that:
|
What is the status of this? Building shared libraries for android doesn't seem to work |
@Hardebayho, in case you never found out, you can set |
@mlugg Yeah, I did find the flag. Thanks |
Thanks for that, let's try integrating it into the Android SDK! |
Just an FYI for anyone building x86 code for Android and using the workaround mentioned above: Then you'll likely hit the following issue when loading your code/APK at runtime:
For context, Android 6.0 is at API Level 23. |
Environment
zig-linux-x86_64-0.8.0-dev.1104+5e81b048a.tar.xz
tarballMinimal reproducible example
zig build-lib output (with `ld.lld` error)
Note
It happens only in
-O Debug
. It doesn't happen in all other-O
modes.Workaround
-z notext
tobuild-lib
command line arguments, like:This option could be set in
build.zig
. As suggested in ld.lld: error: relocation R_386_PC32 cannot be used against symbol __zig_probe_stack #7935 (comment):See pull request #10056 (and merged commit 2cdffc9).
Zig 0.8.1 didn't include this commit, following downloadable releases should allow this workaround. I've tested it with
0.9.0-dev.1561+5ebdc8c46
(released on 2021-11-03).Workaround (for Zig versions released before 29-Oct-2021)
Execute `zig ld.lld` manually with added `-z notext`
ld.lld
invocation arguments.zig ld.lld
manually with added-z notext
.libdummy.so
will be produced.Conclusions
That begs a question: is it or is it not possible to pass freeform extra arguments to internal
zig ld.lld
invocation simply by using additionalzig build-lib
options and/or by using appropriate function inbuild.zig
? (I didn't find a way to do it.)Also I don't know and can't argue whether passing
-z notext
is a safe or right solution. Just reporting that it works.Relevant links
-z notext
TEXTREL
The text was updated successfully, but these errors were encountered: