digitalmars.D.bugs - [Issue 6952] New: Static Linking on Linux
- d-bugmail puremagic.com (43/43) Nov 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6952
- d-bugmail puremagic.com (22/22) Nov 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6952
- d-bugmail puremagic.com (10/10) Nov 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6952
- d-bugmail puremagic.com (6/6) Nov 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6952
http://d.puremagic.com/issues/show_bug.cgi?id=6952
Summary: Static Linking on Linux
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: dsimcha yahoo.com
It seems that the stuff that DMD outputs to GCC on Linux is misconfigured for
static linking. I've observed this on several machines with various Linux
distros, all of which can statically link a C hello world program successfully
with the machine's GCC install.
hello.d:
import std.stdio;
void main() {
write("Hello, world\n");
}
$ dmd -L-static hello.d
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
--- errorlevel 1
Yet somehow when I compile/link a C hello world on the same machine it Just
Works:
hello.c:
#include <stdio.h>
int main() {
printf("Hello, world.\n");
return 0;
}
$ gcc -o hello -static hello.c
$ ./hello
Hello, world.
$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically
linked, for GNU/Linux 2.6.15, not stripped
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6952
Steven Schveighoffer <schveiguy yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy yahoo.com
OS/Version|Windows |Linux
09:40:22 PST ---
The issue is that -Lxxx passes the parameter like this:
-Xlinker xxx
Which means to gcc "pass this argument to the linker"
Whereas your gcc compile line is passing -static to the compiler.
doing this:
gcc -Xlinker -static -o hello hello.c
should result in the same failure (not tested).
It's not that dmd outputs misconfigured code, it's just that the link line is
not geared towards static linking. I'm not sure you want to do static linking
anyways. It's not supported by GCC IIRC.
You can fix this by doing dmd -v, then running the link line, removing the
-Xlinker arg in front of -static.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6952
Jonathan M Davis <jmdavisProg gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg gmx.com
PST ---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6952 05:26:34 PST --- *** Issue 4376 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2011









d-bugmail puremagic.com 