-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
option -lib difference from dmd #579
Comments
dmd has the same behaviour. This fixes issue #579.
Thanks for the great report. It was easier to fix then I expected. :-) |
Wow - that was fast! -lib will be nice for breaking up modules like dmain2.d which has the C main embedded in it. This should allow one to link in another C main() to replace dmain2 C main() without hacking runtime code. And could make for smaller statically linked executables! |
As I said - it was easy to fix. I asked for the report because it helps to track issues (especially if I can't fix them in ten minutes. :-) |
I missed something key here. Went to build phobos using -lib but found modules still not broken into multiple .o's. Turns out it is dmd -multiobj option that is not implemented in ldc. -multiobj breaks up a module into separate obj files, which should help make smaller apps when linking to phobos (link only the functions you need). I didn't realize what was going on until I searched the dmd source code and see that -multiobj is turned on by -lib automatically. Idmd2 accepts -multiobj but does not use. |
LDC: ldc2-0.13.0-alpha1-osx-x86_64.tar.xz
Issue description:
ldmd2 -lib option behaves different from dmd. dmd splits a D module into separate compilation units before building the library. ldmd2 does not split the module.
$ cat >testlib.d <<eof
void foo() {}
void bar() {}
void xyzzy() {}
eof
$ dmd -lib -oflibtest.a testlib.d
$ nm libtest.a
libtest.a(testlib.o):
0000000000000050 D _D7testlib12__ModuleInfoZ
0000000000000030 T _D7testlib15__unittest_failFiZv
0000000000000000 T _D7testlib7__arrayZ
0000000000000018 T _D7testlib8__assertFiZv
U __d_array_bounds
U __d_assertm
U __d_unittestm
libtest.a(testlib_1_144.o):
0000000000000000 S _D7testlib3fooFZv
libtest.a(testlib_2_135.o):
0000000000000000 S _D7testlib3barFZv
libtest.a(testlib_3_25e.o):
0000000000000000 S _D7testlib5xyzzyFZv
Also, noticed that dmd and ldmd2 default library naming is different when -of is not specified. dmd calls the library testlib.a where ldmd2 calls it libtestlib.a.
$ dmd --help
DMD64 D Compiler v2.064
Copyright (c) 1999-2013 by Digital Mars written by Walter Bright
$ ldmd2 --help
LDC - the LLVM D compiler (0.13.0-alpha1):
based on DMD v2.064 and LLVM 3.4
The text was updated successfully, but these errors were encountered: