December 19, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 dawg@dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dawg@dawgfoto.de --- Comment #20 from dawg@dawgfoto.de 2011-12-18 23:12:56 PST --- The core issue is that your gcc is linking PIE by default but PIC support for dmd still has some bug and probably would need more that -fPIC to support PIE. Currently you should pass -fno-pie to gcc for linking. Please help to find out why --export-dynamic is involved. Does it trigger alter the PIE behavior? What's the backtrace of your segfault core dumps? Please list any linker warnings you get (-Wl,--verbose for gcc or -L--verbose for dmd). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 21, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #21 from Chad Joan <chadjoan@gmail.com> 2012-01-20 19:32:30 PST --- (In reply to comment #20) > The core issue is that your gcc is linking PIE by default but PIC support for dmd still has some bug and probably would need more that -fPIC to support PIE. Currently you should pass -fno-pie to gcc for linking. > > Please help to find out why --export-dynamic is involved. Does it trigger alter the PIE behavior? How do I find this out? > What's the backtrace of your segfault core dumps? Also, how do I find this out? Running the program just makes it print "Segmentation fault"; there is no backtrace for me to copy. Maybe I am missing something (where would I find a core dump for this?). > Please list any linker warnings you get > (-Wl,--verbose for gcc or -L--verbose for dmd). Stock DMD v2.057 64-bit: chad@Hugin /mnt/bulk/dprojects/helloD2 $ which dmd /usr/local/share/dcompilers/dmd/linux/bin64/dmd chad@Hugin /mnt/bulk/dprojects/helloD2 $ cat main.d import std.stdio; void main() { writefln("hello world!"); } Without -m32 it isn't able to compile my program: http://pastebin.com/GqP5JC3z With -m32 it does, but segfaults: http://pastebin.com/hd5zEtD2 32-bit dmd: chad@Hugin /mnt/bulk/dprojects/helloD2 $ which dmd /usr/local/share/dcompilers/dmd/linux/bin32/dmd Segfaults: http://pastebin.com/d7miSKtH -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 22, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #22 from dawg@dawgfoto.de 2012-01-21 22:50:46 PST --- What's linker flags are passed by gcc if you use --export-dynamic vs. not using it? dmd -c main ---------- gcc main.o -o main -m32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lphobos2 -lpthread -lm -lrt -v ---------- vs. ---------- gcc main.o -o main -m32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt -v ---------- Also did passing -fno-pie to gcc resolve your problems? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 22, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #23 from Chad Joan <chadjoan@gmail.com> 2012-01-22 09:28:48 PST --- (In reply to comment #22) Thank you for clarifying. > What's linker flags are passed by gcc if you use --export-dynamic vs. not using it? > > dmd -c main > ---------- > gcc main.o -o main -m32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lphobos2 -lpthread -lm -lrt -v http://pastebin.com/BD52Kkp2 > ---------- > vs. > ---------- > gcc main.o -o main -m32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin32/../lib64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt -v (no segfault) http://pastebin.com/0yA29by1 > ---------- > > Also did passing -fno-pie to gcc resolve your problems? Yes. http://pastebin.com/yLQacSuf Those were all 32-bit. I suppose the natural next thing to try is 64-bit: http://pastebin.com/utYgp7YA And yep, -fno-pie makes it run. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 22, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #24 from Chad Joan <chadjoan@gmail.com> 2012-01-22 09:41:55 PST --- (In reply to comment #22) Additional info: I can get basic stack traces now. Yay! And I don't have to use paxctl -m anymore. Also yay! http://pastebin.com/tt784wYr More line numbers in the stack trace would be nice though. I suspect this -fno-pie thing will make shared libraries impossible on my setup until this gets resolved though, right? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 23, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 dawg@dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #25 from dawg@dawgfoto.de 2012-01-22 16:57:07 PST --- >I suspect this -fno-pie thing will make shared libraries impossible on my setup until this gets resolved though, right? No, it doesn't. PIE simply means randomized address space for the executable. I do even think that PIE should work out of the box if you compile phobos and you executables with -fPIC. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 26, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #26 from Chad Joan <chadjoan@gmail.com> 2012-01-25 21:05:07 PST --- (In reply to comment #25) > >I suspect this -fno-pie thing will make shared libraries impossible on my setup until this gets resolved though, right? > No, it doesn't. > PIE simply means randomized address space for the executable. > I do even think that PIE should work out of the box if you > compile phobos and you executables with -fPIC. Oh, my bad. I confused PIE with PIC. So, just to be clear, -fpie is not passed by default on most systems, but it is on mine (a feature of the hardened GCC). DMD's binary release of phobos is then compiled WITHOUT -fpie because that's the usual course of things, thus causing it to complain when I link it with something that compiles WITH -fpie. Is there any chance that -fno-pie could make it into the list of things DMD passes to GCC by default? Assuming I understand this all correctly, then other systems won't care if -fno-pie gets passed because they don't use PIE anyways. On my system it will convert a dead-on-arrival binary release into something that works. If someone still wanted to build with PIE then the ideal, I suppose, would be to have portage (the package manager) build everything from source, adding -fpie and -fPIC as necessary and adjusting the dmd.conf file to reflect it. Also, is it even possible to get -fno-pie in there through dmd.conf? When I add -L-fno-pie in dmd.conf it adds "-Xlinker -fno-pie" instead of just "-fno-pie" to the GCC args and it seems to end up going to the wrong place. Then I get linker errors and stuff won't build: http://pastebin.com/wEcuyUqp -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 05, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 Chad Joan <chadjoan@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | --- Comment #27 from Chad Joan <chadjoan@gmail.com> 2012-02-04 19:21:23 PST --- I'm reopening this because DMD won't work on my system unless -fno-pie is passed to GCC by DMD itself. I can't even fix this without recompiling DMD because if I add "-L-fno-pie" to dmd.conf then will put "-Xlinker" before that and GCC itself never sees the "-fno-pie". (See my previous comment for more detail.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 05, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #29 from Chad Joan <chadjoan@gmail.com> 2012-02-05 14:06:08 PST --- (In reply to comment #28) > Yeah, it's a limitation that dmd doesn't let you pass flags to gcc. It's a different bug though. > > Have you actually tried to build PIE using dmd's -fPIC flag. You'd need to rebuild druntime and phobos with the fPIC too. I think PIE will work without further changes. It seemed like it was working before, but I did it again with more rigor to try and confirm that all of the flags are what I think they are. It didn't work too well. Here's what happened: druntime compile: http://pastebin.com/e5HjcVRb phobos compile: http://pastebin.com/4uATCBt1 executable compile: chad@Hugin /mnt/bulk/dprojects/helloD2 $ dmd -fPIC -c main.d chad@Hugin /mnt/bulk/dprojects/helloD2 $ gcc main.o -o main -m32 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin/../lib -lphobos2 -lpthread -lm -lrt -fPIC -pie /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object. chad@Hugin /mnt/bulk/dprojects/helloD2 $ main main: error while loading shared libraries: cannot make segment writable for relocation: Permission denied chad@Hugin /mnt/bulk/dprojects/helloD2 $ sudo paxctl -m main chad@Hugin /mnt/bulk/dprojects/helloD2 $ main Killed chad@Hugin /mnt/bulk/dprojects/helloD2 $ If I did something wrong, please let me know a better way. What's the issue# for the bug preventing DMD from forwarding arguments to GCC? It's actually really easy to write a patch for that. In fact, I did it so that I could continue working on my system. Otherwise there is no way for me to have DMD work on my system without hardcoding "-fno-pie" into dmd/src/link.c and compiling from git. Now, this is probably the wrong place for it, and I could stand to improve it slightly and make sure it works off of the latest git sources (I was working offline with this), but here is the patch for adding a -cflags parameter in DMD, just in case anyone wants it: http://pastebin.com/U6cTmryQ -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 10, 2012 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 Chad Joan <chadjoan@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |7678 Severity|blocker |major -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation