On Thursday, 3 November 2016 at 06:11:48 UTC, rikki cattermole
wrote:
Took me a while to replicate your build environment but it
looks like a false alarm.
rikki@debian:/tmp/test$ dmd test.d
rikki@debian:/tmp/test$ file test
test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 2.6.32,
BuildID[sha1]=0a6394b9ec9b82e07440ab62cd71932f0ab568d1, not
stripped
rikki@debian:/tmp/test$ ./test
Edit source/app.d to start your project.
rikki@debian:/tmp/test$ cat /etc/dmd.conf
;
; dmd.conf file for dmd
;
; dmd will look for dmd.conf in the following sequence of
directories:
; - current working directory
; - directory specified by the HOME environment variable
; - directory dmd resides in
; - /etc directory
;
; Names enclosed by %% are searched for in the existing
environment and inserted
;
; The special name %@P% is replaced with the path to this file
;
[Environment32]
DFLAGS=-I/usr/include/dmd/phobos
-I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu
-L--export-dynamic -fPIC -defaultlib=libphobos2.so
[Environment64]
DFLAGS=-I/usr/include/dmd/phobos
-I/usr/include/dmd/druntime/import
-L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic -fPIC
-defaultlib=libphobos2.so
Thanks for looking at it and confirming you are seeing the same
thing.
I am no expert, but after some additional research I think I see
what is going on. From what I read the gcc -fPIC option creates
a shared library, while gcc -fPIE option creates an executable.
You can also create a dual purpose file that is a shared library
and is also executable by creating a shared library if that file
also contains a main function (that might be oversimplified a
little bit).
Looking at the dmd documentation, it only has a -fPIC option,
there is no -fPIE option, which has the following description:
generate Position Independent Code (which is used for building
shared libraries).
So, if I am understanding everything correctly because dmd only
has -fPIC, the only option is to create a dual purpose file that
is both a shared library and executable.