www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - dmd and Archlinux

reply Antonio Corbi <aaacorbi mail.com> writes:
Hi!

Are there any news about the status of packaging dmd for 
archlinux?

The last dmd compiler packaged is 2.074.0 and since the last 
batch of updated packages in archlinux, dmd generated objects 
fail to link with libphobos with erros like these:

/usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation 
R_X86_64_32 against `.rodata.str1.1' can not be used when making 
a shared object; recompile con -fPIC
/usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation 
R_X86_64_32 against `.rodata.str1.1' can not be used when making 
a shared object; recompile con -fPIC
/usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation 
R_X86_64_32 against `.rodata.str1.1' can not be used when making 
a shared object; recompile con -fPIC
/usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation 
R_X86_64_32 against `.rodata.str1.1' can not be used when making 
a shared object; recompile con ...

A. Corbi
Jul 09 2017
next sibling parent reply Nemanja Boric <4burgos gmail.com> writes:
On Sunday, 9 July 2017 at 18:35:09 UTC, Antonio Corbi wrote:
 Hi!

 Are there any news about the status of packaging dmd for 
 archlinux?

 The last dmd compiler packaged is 2.074.0 and since the last 
 batch of updated packages in archlinux, dmd generated objects 
 fail to link with libphobos with erros like these:

 /usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con ...

 A. Corbi
Hm, I can't reproduce this issue with dmd 2.074.0-1. I've just installed dmd and it works out of the box: ``` ➜ arch tmp% pacman -Q | grep phob libphobos-devel 1:2.074.0-1 ➜ arch tmp% pacman -Q | grep dmd dmd 1:2.074.0-1 ➜ arch tmp% cat test.d import std.stdio; void main() { writeln("hello!"); } ➜ arch tmp% dmd -c test.d ➜ arch tmp% dmd test.o ➜ arch tmp% ./test hello! ```
Jul 09 2017
parent Antonio Corbi <amcb ggmail.com> writes:
On Sunday, 9 July 2017 at 19:15:15 UTC, Nemanja Boric wrote:
 On Sunday, 9 July 2017 at 18:35:09 UTC, Antonio Corbi wrote:
 [...]
Hm, I can't reproduce this issue with dmd 2.074.0-1. I've just installed dmd and it works out of the box: ``` ➜ arch tmp% pacman -Q | grep phob libphobos-devel 1:2.074.0-1 ➜ arch tmp% pacman -Q | grep dmd dmd 1:2.074.0-1 ➜ arch tmp% cat test.d import std.stdio; void main() { writeln("hello!"); } ➜ arch tmp% dmd -c test.d ➜ arch tmp% dmd test.o ➜ arch tmp% ./test hello! ```
Thank's! In my case the error persists. I'm using the testing repo...so I think it must be related to that. A. Corbi
Jul 09 2017
prev sibling next sibling parent reply Seb <seb wilzba.ch> writes:
On Sunday, 9 July 2017 at 18:35:09 UTC, Antonio Corbi wrote:
 Hi!

 Are there any news about the status of packaging dmd for 
 archlinux?

 The last dmd compiler packaged is 2.074.0 and since the last 
 batch of updated packages in archlinux, dmd generated objects 
 fail to link with libphobos with erros like these:

 /usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making a shared object; recompile con ...

 A. Corbi
I think the Arch Linux TUs are in the process of enabling -fPIC by default, see e.g. [1] - it might be releated to this? In any case - building dmd/druntime/phobos with -fPIC enabled is a good idea and since 2.072.2 the official releases do so. Not sure why it's not done on Arch, maybe because Dicebot stepped down as maintainer? (see [2, 3]). [1] https://lists.archlinux.org/pipermail/arch-dev-public/2017-July/028918.html [2] http://forum.dlang.org/post/o6fbbu$1qli$1 digitalmars.com [3] http://forum.dlang.org/post/o6sldo$1pad$1 digitalmars.com
Jul 09 2017
parent reply Antonio Corbi <amcb ggmail.com> writes:
On Sunday, 9 July 2017 at 19:21:48 UTC, Seb wrote:
 On Sunday, 9 July 2017 at 18:35:09 UTC, Antonio Corbi wrote:
 [...]
I think the Arch Linux TUs are in the process of enabling -fPIC by default, see e.g. [1] - it might be releated to this? In any case - building dmd/druntime/phobos with -fPIC enabled is a good idea and since 2.072.2 the official releases do so. Not sure why it's not done on Arch, maybe because Dicebot stepped down as maintainer? (see [2, 3]). [1] https://lists.archlinux.org/pipermail/arch-dev-public/2017-July/028918.html [2] http://forum.dlang.org/post/o6fbbu$1qli$1 digitalmars.com [3] http://forum.dlang.org/post/o6sldo$1pad$1 digitalmars.com
Hi Seb! I think you are right. Official releases (the ones downloaded from dlang.org via curl) work for me. A. Corbi
Jul 09 2017
parent Seb <seb wilzba.ch> writes:
On Sunday, 9 July 2017 at 19:33:45 UTC, Antonio Corbi wrote:
 On Sunday, 9 July 2017 at 19:21:48 UTC, Seb wrote:
 On Sunday, 9 July 2017 at 18:35:09 UTC, Antonio Corbi wrote:
 [...]
I think the Arch Linux TUs are in the process of enabling -fPIC by default, see e.g. [1] - it might be releated to this? In any case - building dmd/druntime/phobos with -fPIC enabled is a good idea and since 2.072.2 the official releases do so. Not sure why it's not done on Arch, maybe because Dicebot stepped down as maintainer? (see [2, 3]). [1] https://lists.archlinux.org/pipermail/arch-dev-public/2017-July/028918.html [2] http://forum.dlang.org/post/o6fbbu$1qli$1 digitalmars.com [3] http://forum.dlang.org/post/o6sldo$1pad$1 digitalmars.com
Hi Seb! I think you are right. Official releases (the ones downloaded from dlang.org via curl) work for me. A. Corbi
Maybe phobos/5586 [1] helps us. Of course the package would need to be rebuilt by the Arch Linux maintainers. Something I am not sure whether they are interested - the packages are orphaned and flagged out-of-date since more than a month [2]. Maybe you have an idea? [1] https://github.com/dlang/phobos/pull/5586 [2] http://forum.dlang.org/post/ppyeysvwmgjpchazuuwk forum.dlang.org
Jul 09 2017
prev sibling parent reply Marco Leise <Marco.Leise gmx.de> writes:
Am Sun, 09 Jul 2017 18:35:09 +0000
schrieb Antonio Corbi <aaacorbi mail.com>:

 Hi!
 
 Are there any news about the status of packaging dmd for 
 archlinux?
 
 The last dmd compiler packaged is 2.074.0 and since the last 
 batch of updated packages in archlinux, dmd generated objects 
 fail to link with libphobos with erros like these:
 
 /usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when making 
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when making 
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when making 
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation 
 R_X86_64_32 against `.rodata.str1.1' can not be used when making 
 a shared object; recompile con ...
 
 A. Corbi
The linker gold (since binutils 2.27) is problematic with DMD and would emit such errors. (Is ld a symlink to ld.gold in this case?) Also binutils 2.28 breaks how DMD's druntime loads shared libraries. You have to either downgrade binutils or use the hack of adding '-fPIC' when compiling executable that link against shared libraries. binutils 2.26 should be the most compatible version for the time being. -- Marco
Jul 10 2017
parent reply Seb <seb wilzba.ch> writes:
On Tuesday, 11 July 2017 at 00:23:55 UTC, Marco Leise wrote:
 Am Sun, 09 Jul 2017 18:35:09 +0000
 schrieb Antonio Corbi <aaacorbi mail.com>:

 Hi!
 
 Are there any news about the status of packaging dmd for 
 archlinux?
 
 The last dmd compiler packaged is 2.074.0 and since the last 
 batch of updated packages in archlinux, dmd generated objects 
 fail to link with libphobos with erros like these:
 
 /usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con ...
 
 A. Corbi
The linker gold (since binutils 2.27) is problematic with DMD and would emit such errors. (Is ld a symlink to ld.gold in this case?) Also binutils 2.28 breaks how DMD's druntime loads shared libraries. You have to either downgrade binutils or use the hack of adding '-fPIC' when compiling executable that link against shared libraries. binutils 2.26 should be the most compatible version for the time being.
mleise: OP is using the testing repos where the PIE enforcement already landed [1], but libphobos.a isn't built with -fPIC on Arch yet. The Arch developers, however, are aware of the need to rebuild libphobos [2], but maybe we can simply build Phobos with -fPIC by default on Posix [3]. [1] https://www.archlinux.org/todo/pie-rebuild [2] https://bugs.archlinux.org/task/54749 [3] https://github.com/dlang/phobos/pull/5586
Jul 11 2017
next sibling parent reply Jonathan M Davis via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Tuesday, July 11, 2017 12:00:51 PM MDT Seb via Digitalmars-d wrote:
  mleise: OP is using the testing repos where the PIE enforcement
 already landed [1], but libphobos.a isn't built with -fPIC on
 Arch yet.
 The Arch developers, however, are aware of the need to rebuild
 libphobos [2], but maybe we can simply build Phobos with -fPIC by
 default on Posix [3].

 [1] https://www.archlinux.org/todo/pie-rebuild
 [2] https://bugs.archlinux.org/task/54749
 [3] https://github.com/dlang/phobos/pull/5586
PIC and PIE may make sense from security perspective, but they've sure made dealing with some the Linux distros over the last year or so a bit of a pain. - Jonathan M Davis
Jul 11 2017
parent Marco Leise <Marco.Leise gmx.de> writes:
Am Tue, 11 Jul 2017 06:21:33 -0600
schrieb Jonathan M Davis via Digitalmars-d
<digitalmars-d puremagic.com>:

 On Tuesday, July 11, 2017 12:00:51 PM MDT Seb via Digitalmars-d wrote:
  mleise: OP is using the testing repos where the PIE enforcement
 already landed [1], but libphobos.a isn't built with -fPIC on
 Arch yet.
 The Arch developers, however, are aware of the need to rebuild
 libphobos [2], but maybe we can simply build Phobos with -fPIC by
 default on Posix [3].

 [1] https://www.archlinux.org/todo/pie-rebuild
 [2] https://bugs.archlinux.org/task/54749
 [3] https://github.com/dlang/phobos/pull/5586  
PIC and PIE may make sense from security perspective, but they've sure made dealing with some the Linux distros over the last year or so a bit of a pain. - Jonathan M Davis
It adds to security and adds another shovel of dirt on the grave of x86. X86 needs to emulate access to global constants in PIE, while amd64 is using offsets relative to the instruction pointer. RIP x86. (pun intended!) -- Marco
Jul 12 2017
prev sibling parent reply Seb <seb wilzba.ch> writes:
On Tuesday, 11 July 2017 at 12:00:51 UTC, Seb wrote:
 On Tuesday, 11 July 2017 at 00:23:55 UTC, Marco Leise wrote:
 Am Sun, 09 Jul 2017 18:35:09 +0000
 schrieb Antonio Corbi <aaacorbi mail.com>:

 Hi!
 
 Are there any news about the status of packaging dmd for 
 archlinux?
 
 The last dmd compiler packaged is 2.074.0 and since the last 
 batch of updated packages in archlinux, dmd generated objects 
 fail to link with libphobos with erros like these:
 
 /usr/bin/ld: /usr/lib/libphobos2.a(object_a_66e.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_b_58c.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_c_7f4.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con -fPIC
 /usr/bin/ld: /usr/lib/libphobos2.a(object_d_a07.o): relocation
 R_X86_64_32 against `.rodata.str1.1' can not be used when 
 making
 a shared object; recompile con ...
 
 A. Corbi
The linker gold (since binutils 2.27) is problematic with DMD and would emit such errors. (Is ld a symlink to ld.gold in this case?) Also binutils 2.28 breaks how DMD's druntime loads shared libraries. You have to either downgrade binutils or use the hack of adding '-fPIC' when compiling executable that link against shared libraries. binutils 2.26 should be the most compatible version for the time being.
mleise: OP is using the testing repos where the PIE enforcement already landed [1], but libphobos.a isn't built with -fPIC on Arch yet. The Arch developers, however, are aware of the need to rebuild libphobos [2], but maybe we can simply build Phobos with -fPIC by default on Posix [3]. [1] https://www.archlinux.org/todo/pie-rebuild [2] https://bugs.archlinux.org/task/54749 [3] https://github.com/dlang/phobos/pull/5586
Bumping this as the PIE changes have been moved to core and as the maintainers haven't rebuilt Phobos with PIE yet, one will see messages like: /usr/local/bin/ld: error: /usr/lib/libphobos2.a(encoding_4bd_6d6.o): requires dynamic R_X86_64_32 reloc which may overflow at runtime; recompile with -fPIC A quick fix is: curl https://i.dlang.io | bash -s dmd-2.074.0 sudo cp ~/dlang/dmd-2.074.0/linux/lib64/libphobos2.a /usr/lib The official releases [1] are built with PIE=1 [1] http://dlang.org/download.html
Jul 15 2017
parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Saturday, 15 July 2017 at 19:00:57 UTC, Seb wrote:
 Bumping this as the PIE changes have been moved to core and as 
 the maintainers haven't rebuilt Phobos with PIE yet, one will 
 see messages like:
Looks like dmd got bumped to 2.075, and the problem is now finally gone :) Thanks to Antonio Rojas for updating the package!
Jul 19 2017