Skip to content
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

Provide way to compile with LDC and without dub #387

Closed
ximion opened this issue Jul 12, 2016 · 17 comments
Closed

Provide way to compile with LDC and without dub #387

ximion opened this issue Jul 12, 2016 · 17 comments
Labels

Comments

@ximion
Copy link
Collaborator

ximion commented Jul 12, 2016

Hi!
Since dub isn't really ready yet for proper Debian packaging, I am trying to use Automake instead.
When changing dmd in configure.ac to ldc2, the build fails with

/usr/bin/ldc2 -O -I/usr/include/d/gtkd-3/ -L-lvted-3 -L-L/usr/lib/x86_64-linux-gnu/ -L-lgtkd-3 -L-ldl -c source/app.d source/gx/gtk/cairo.d source/gx/gtk/vte.d source/gx/gtk/resource.d source/gx/gtk/util.d source/gx/gtk/actions.d source/gx/gtk/threads.d source/gx/terminix/appwindow.d source/gx/terminix/constants.d source/gx/terminix/preferences.d source/gx/terminix/shortcuts.d source/gx/terminix/colorschemes.d source/gx/terminix/profilewindow.d source/gx/terminix/terminal/search.d source/gx/terminix/terminal/vtenotification.d source/gx/terminix/terminal/layout.d source/gx/terminix/terminal/actions.d source/gx/terminix/terminal/terminal.d source/gx/terminix/encoding.d source/gx/terminix/common.d source/gx/terminix/prefwindow.d source/gx/terminix/sidebar.d source/gx/terminix/application.d source/gx/terminix/session.d source/gx/terminix/cmdparams.d source/gx/util/array.d source/gx/i18n/l10n.d -ofterminix.o
Error: multiple source files, but only one .obj name

Fixing this somehow will be necessary to properly build Terminix.
Also, the Automake script seems to sometimes ignore a missing D compiler, which leads to strange results, including only data files being installed.

It looks like Automake attempts to compile all packages in one go, instead of compiling the sources separately and linking them together.

@ximion ximion changed the title Provide wy to compile with LDC without dub Provide way to compile with LDC and without dub Jul 12, 2016
@gnunn1
Copy link
Owner

gnunn1 commented Jul 12, 2016

I'm not sure what the issue is but I'll have a look unless @dsboger beats me to it.

@gnunn1 gnunn1 added the bug label Jul 12, 2016
@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

@gnunn1 We might be able to build Terminix with dub by patching the dub.json and using the dynamic profile, but this is blocked until a couple of really weird LDC bugs are fixed (see ldc-developers/ldc#1618 - not sure who is to blame yet...)

@gnunn1
Copy link
Owner

gnunn1 commented Jul 12, 2016

@ximion One thing that strikes me as interesting is that the Travis CI build which is using LDC is working fine, albeit that is with dub and not automake. I'm not familiar enough with either LDC or automake at this point to offer more detailed insight, but thought it was an interesting factoid.

@dsboger-zz
Copy link
Contributor

dsboger-zz commented Jul 12, 2016

My grasp of the Terminix + LDC situation right now is the following (I'm not sure of these claims, except for the ones I've tested):

  • It works with stock versions if everything is statically linked (including using dub, it seems, but I've not tested this scenario)
  • It works with LDC from git master if everything is dynamically linked (I tested this configuration using autotools and GtkD as built and packaged in AUR)
  • LDC does not support mixing static/dynamic linking and that must be decided when building LDC and phobos-ldc (I've not tested this also).

I have a couple of commits that generalize autotools to support LDC, but as latest version of LDC still does not work with dynamic linking, I'm waiting for the next version of LDC before pushing those commits. I can push them and PR if someone else wants to test.

@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

Hmm, can we isolate the patches in LDC that make this work properly? Then we could apply them to our packaging to make this work...

@dsboger-zz
Copy link
Contributor

@ximion ldc-developers/ldc#1534 points to a couple of commits that fix the issues I had.

Reading that bug again, looks like there is a flag -disable-linker-strip-dead that can be passed to LDC as a workaround. That may work with latest stable release, but I have not tested it. I think you can give it a try adapting the instructions in the Wiki. You can build GtkD with LDC passing DC="ldc" instead of DC="dmd" and I think using make DC="ldmd -disable-linker-strip-dead" to build Terminix should work. I might try it later today, if time permits.

@dnadlinger
Copy link

LDC does not support mixing static/dynamic linking

This is indeed true, but also applies to DMD. More precisely, whenever you actually want to build a dynamic library out of your D code, you also need to link against druntime/Phobos as shared libraries. And if this library is to be linked against/loaded from a D executable, that binary also needs to the same druntime/Phobos shared objects.

-disable-linker-strip-dead does not change anything about these constraints. It just causes LDC not to use --gc-sections, which we've noticed to frequently trigger linker bugs (e.g. in the case you linked).

@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

We will likely make LDC the default D compiler for Debian, when it works, and use a shared Phobos / DRuntime for all packages, so this issue shouldn't exist.

Btw, GtkD is now available in Debian ;-) (since a few minutes). Since LDC is busted, it will take a while though for this to enter testing and Ubuntu (depending on how quickly we can resolve LDC issues).

@dsboger-zz
Copy link
Contributor

dsboger-zz commented Jul 12, 2016

@klickverbot Thanks for clarifying!

@ximion I just built Terminix with the instructions I gave above and it works. I'm thinking of changing terminix-git AUR package to use LDC.

@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

@dsboger Which version of GCC / LLVM do you use?

@dsboger-zz
Copy link
Contributor

@ximion I'm using latest Arch Linux: gcc-multilib 6.1.1-2, llvm 3.8.0-1.

@dsboger-zz
Copy link
Contributor

I decided to try and PR the LDC support in autotools because the current settings will have problems if there is a gtkd-dmd installed. As soon as that PR is merged, if my tests pass I'll update terminix-git in AUR to use LDC.

@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

@dsboger Oh wow, using the very same ldmd trick works here as well to get Terminix to compile - dub is still broken, and anything compiling with ldc directly also fails, but this works.
That's really weird...
I also get lots of symbol issues when compiling with ldc and dub, which all vanish when using make DC=ldmd2.
Btw, sorry for misusing the bug report for something which is starting to look more like a support group :D

@dsboger-zz
Copy link
Contributor

@ximion The ldc issues may be related to the fact that ldc and ldmd have different command-line syntax? ldmd and ldmd2 (those are symlinked here) are wrappers that emulate the dmd syntax. I use that to simplify the makefiles.

@ximion
Copy link
Collaborator Author

ximion commented Jul 12, 2016

@dsboger There is always a chance that some buildflags are injected into the package build process e.g. to enable hardening, which don't apply to ldmd... But I would be really surprised here if that was the case.
I think there must be something else ldmd does differently.

@dsboger-zz
Copy link
Contributor

terminix-git in AUR now compiles with LDC using autotools. It is working for me. I think this issue can be closed, as long as others can confirm the build process works.

As a side note, is it possible and/or desirable to include building with autotools into the CI script?

@ximion
Copy link
Collaborator Author

ximion commented Jul 13, 2016

I can confirm it's working.
Adding a test for Autottools to the CI seems to be useful to me (test everything that might break!).

@ximion ximion closed this as completed Jul 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants