Bug 237427 - lang/ldc: update to 1.15.0, unbreak on aarch64
Summary: lang/ldc: update to 1.15.0, unbreak on aarch64
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jose Alonso Cardenas Marquez
Depends on:
Reported: 2019-04-20 23:58 UTC by Greg V
Modified: 2019-07-09 20:22 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (acm)

ldc115.patch (10.92 KB, patch)
2019-04-20 23:58 UTC, Greg V
no flags Details | Diff
ldc115.patch v2 (10.66 KB, patch)
2019-04-21 14:31 UTC, Greg V
no flags Details | Diff
Possible replacement/update of the previous patch (30.51 KB, patch)
2019-06-20 18:23 UTC, Diederik de Groot
no flags Details | Diff
ldc116.patch (34.54 KB, patch)
2019-07-09 20:22 UTC, Greg V
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg V 2019-04-20 23:58:17 UTC
Created attachment 203847 [details]

and use ninja to build the bootstrap compiler quickly and in parallel.

v1.15.0 relnotes: https://github.com/ldc-developers/ldc/releases/tag/v1.15.0

This version brings LLVM 8 support, however not in ltsmaster it seems:

FAILED: dmd2/impcnvgen 
: && /usr/bin/c++     CMakeFiles/impcnvgen.dir/dmd2/impcnvgen.c.o  -o dmd2/impcnvgen   && :
ld: error: undefined symbol: llvm::DisableABIBreakingChecks

Might be worth it to use LLVM 7 for bootstrap and 8 for the final compiler. And to rebuild the final compiler with itself because the lowmem option (see relnotes) sounds pretty cool. But I'm not very interested in all that right now, that's just notes for later.
Comment 1 Jose Alonso Cardenas Marquez freebsd_committer 2019-04-21 01:25:49 UTC
What version of FreeBSD are you using? Did you test it on FreeBSD 12? I see that you removed two patch files and they are necessary for ldc compiles/works fine on FreeBSD >=12

On another hand, I can't commit ldc 1.15.x update until that all ports that depends of this compiler work fine with it
Comment 2 Greg V 2019-04-21 14:24:20 UTC
(In reply to Jose Alonso Cardenas Marquez from comment #1)

I tested on CURRENT.

These patches did not apply, I thought they were upstreamed, but this must've been an error on my side, it makes no sense that they would merge only one of the files.
Comment 3 Greg V 2019-04-21 14:31:41 UTC
Created attachment 203864 [details]
ldc115.patch v2

Regenerated dirent patch instead of removing
Comment 4 Greg V 2019-05-01 15:53:24 UTC
Comment 5 Diederik de Groot 2019-06-15 11:32:16 UTC

The `ld: error: undefined symbol: llvm::DisableABIBreakingChecks` is still remains when building the bootstrap compiler. This might have already been resolved in 1.16.0-beta2. For 1.15.0 it might be better to stick with llvm70 (as a quick fix). Won't be long for 1.16.0 to be released anyway.

Also did you upstream the patches for setjmp.d, ucontext.d and gammafunction.d ?

BTW: You could do: 
and replace:

See: /usr/ports/Mk/Uses/ninja.mk
Comment 6 Greg V 2019-06-15 13:29:44 UTC
(In reply to Diederik de Groot from comment #5)

Yes, I mentioned that in the comment at the beginning of the patch. It's been upstreamed quite some time ago https://github.com/dlang/druntime/pull/2269 and merged into ldc's master. But wasn't cherry-picked into bootstrap/ltsmaster (you can see the patch here is only for ltsmaster). I pinged them two months ago to cherry-pick it, guess I need to send another reminder :)

And yeah, the patch currently uses llvm70 already
Comment 7 Diederik de Groot 2019-06-16 18:32:37 UTC
(In reply to Greg V from comment #6)

To be able to compile ltsmaster with llvm80 would require quite a number of patches. So llvm70 seems the better choice for the bootstrap compiler. If need be we would also download a freebsd precompiled bootstrap compiler (as is done for other languages like ada/go/gcc etc.

If you do want to compile ltsmaster with llvm70 and 1.15.0 with ${LLVM_DEFAULT}, then it might be a good idea to split the Makefile into two steps (Makefile and Makefile.bootstrap) (to ease maintenance). Logically the divide between bootstrap and end compiler will only increase over time. For 1.15.0 it might still be the easier way to just force llvm70 (for now).
Comment 8 Diederik de Groot 2019-06-20 18:23:24 UTC
Created attachment 205239 [details]
Possible replacement/update of the previous patch

Split the Makefile in two parts to ease bootstrapping in the future
Search for pre-existing, usable d-compiler for bootstrapping purposes
Use FLAVORS for llvm70 and llvm80 (which can both be installed at the same time)
Comment 9 Diederik de Groot 2019-06-20 19:23:10 UTC
(In reply to Diederik de Groot from comment #8)

(I reused part of Greg_v's previous patch)

- When no previously installed suitable d-compiler can be found, it automatically falls back to building the ltsmaster based bootstrap compiler.
- the ltsmaster bootstrap compiler is build with llvm70 (for now, as it is not yet made compatible with llvm80).
- Both flavors can be installed at the same time (under /usr/local/llvmXX-ldc (similar llvmXX itself).
- When no /usr/local/bin/ldc2 binary is find, a link is created to the llvmXX-ldc/bin/ldc2, to make the d compiler easier to be found.
- WIP: Mk/Uses/dcompiler.mk (See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230517), so that other d ports can be made easier. And ldc2/gdc can be used to bootstrap lang/dmd,

@Greg_V: Hopefully i did not offend by supplying a potential replacement for your patch and and link it to your bug-report.
Comment 10 Greg V 2019-06-20 19:44:12 UTC
(In reply to Diederik de Groot from comment #9)

Nice. Ideally, poudriere would somehow be instructed to build ltsmaster, build current ldc, and then rebuild current ldc with itself..

btw, I received a report of an "intrinsics error on memcpy when linking tilix" with llvm70 on 12-stable, and reverting to llvm60 as a fix. (I asked for the error message.)

also re: dcompiler.mk (or ports framework in general): all Meson-built D programs need SSP_UNSAFE=yes because Meson currently likes to shove C flags into D compiler args https://github.com/mesonbuild/meson/issues/5369
Comment 11 Diederik de Groot 2019-06-20 19:57:02 UTC
(In reply to Greg V from comment #10)

Funny little thing i noticed. Currently ldc will build find with ltsmaster or any d-compiler with 0.79.1 > druntime < 0.84.0. But not with ldc-0.15.1 (or higher). So at the moment you cannot build 0.15.1 with 0.15.1 :-). I guess i will have to create an upstream issue for that.

re: meson. Does that mean the dcompile.mk would have to have SSP_UNSAFE=yes in it (by default) ?

Have not tried compiling with poudriere or meson so far. I thought it would be wise to first check the waters, in regard to pushing a patch to someone else's bug-report (yours in this case). If you like my solution, you can set your patch to obsolete.
Comment 12 Diederik de Groot 2019-06-20 20:08:23 UTC
(In reply to Greg V from comment #10)
Adding llvm60 as another flavor should not be an issue (i think)

I was planning to add a couple of arguments the dcompiler.mk script something like 
USES=dcompiler:llvm60-ldc or USES=dcompiler:ldc,llvm60
USES=dcompiler:minver=0.15.1,mindrt=20850  (not sure if this is possible)

So when they are in place, that would take care of the tilix requirement.
Comment 13 Greg V 2019-07-07 22:36:18 UTC
Some D news:

- a (WIP) patch for LLVM 8 support in ltsmaster was published https://github.com/ldc-developers/ldc/pull/3092
- I have discovered that the ino64 (freebsd12) patch in ports missed dirent/readdir..
- and I made a 32-bit-inode versioned symbols patch to replace it: https://github.com/dlang/druntime/pull/2668
- I also published ldc patches for enabling dead code elimination via gc-symbols and making LTO with LLD work without a path to the gold LTO plugin: https://github.com/ldc-developers/ldc/pull/3105 https://github.com/ldc-developers/ldc/pull/3106

> re: meson. Does that mean the dcompile.mk would have to have SSP_UNSAFE=yes in it (by default) ?

Maybe we should just patch meson..

I'll look into sending a pull request to meson.
Comment 14 Greg V 2019-07-09 20:22:19 UTC
Created attachment 205633 [details]

Back to packaging, here's 1.16.0,
tested on -CURRENT both amd64 and aarch64,
includes the bootstrap makefile split from Diederik de Groot's version (but not the flavors),
includes my patches for backtrace, lto, gc-sections, FreeBSD 11 ABI versioned symbols for building on >=12.

- I don't really like llvmXX flavors..
  - old llvm versions are pkg bloat, everything should move to latest LLVM when possible;
  - 'pkg install ldc' is a nicer command;
  - more serious reason: 'LIB_DEPENDS=libphobos2-ldc-shared.so:lang/ldc' in dynamically linked ports would not work! the port would have to know the ldc flavor and ugh this is too complex.
  - (maybe USES=dcompiler could manage the complexity, but we have one version currently, let's have just one version for as long as possible maybe?)
- I'm not sure where you got that DRUNTIME_MAXVER thing from — I've never had a problem building current (not bootstrap) ldc with itself.
- for some reason I've ended up the final compiler linked dynamically to bootstrap's phobos/druntime once.. but can't reproduce now even with no special flags that make the bootstrap only build static libs
- the check for existing D compilers spams 'sh: --version: not found' (for every not-installed compiler) and I haven't fixed that