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

druntime C parts of binary releases not built with PIC #2008

Closed
dnadlinger opened this issue Feb 18, 2017 · 2 comments
Closed

druntime C parts of binary releases not built with PIC #2008

dnadlinger opened this issue Feb 18, 2017 · 2 comments
Milestone

Comments

@dnadlinger
Copy link
Member

dnadlinger commented Feb 18, 2017

On a fresh Ubuntu 16.10 image:

ubuntu@ubuntu:~$ echo 'void main() { import std.stdio; writeln("Hello World!"); }' > test.d
ubuntu@ubuntu:~$ ldc2-1.1.0-linux-x86_64/bin/ldc2 test.d
/usr/bin/ld: /home/ubuntu/ldc2-1.1.0-linux-x86_64/bin/../lib/libdruntime-ldc.a(errno.c.o): relocation R_X86_64_PC32 against symbol `__errno_location@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1

In Ubuntu 16.10 (and newer), they patched the linker to make position-independent code the default even for executables (to enable ASLR, …). As a consequence, we chose to default to PIC on Linux as well. However, this applies only to the ldc2 output and not the C parts of the runtime – since we build on an old Ubuntu version, gcc still defaults to non-PIC code. As a result, libdruntime-ldc.a is incompatible with the implicit PIE default of the system linker.

We need to push out a 1.1.1 release with this issue fixed.

@kinke
Copy link
Member

kinke commented Feb 18, 2017

Ah, so that's the issue the guy in the forum had.

@dnadlinger
Copy link
Member Author

It seems that way. Just found it on an EC2 instance.

dnadlinger added a commit to dnadlinger/ldc that referenced this issue Feb 19, 2017
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Feb 19, 2017
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Feb 19, 2017
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Feb 19, 2017
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Feb 19, 2017
@JohanEngelen JohanEngelen added this to the 1.1.1 milestone Feb 19, 2017
dnadlinger added a commit that referenced this issue Feb 19, 2017
dnadlinger added a commit that referenced this issue Feb 19, 2017
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

3 participants