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

gdc: init at 9.3.0 #69144

Merged
merged 1 commit into from May 23, 2020
Merged

gdc: init at 9.3.0 #69144

merged 1 commit into from May 23, 2020

Conversation

@SFrijters
Copy link
Member

SFrijters commented Sep 20, 2019

Motivation for this change

As of version 9, GCC has a front-end for the D language, but the option to do so has not yet been included in nixpkgs. Packaging has been requested before and this is an attempt to move forward #68419 .

However, in the current state it doesn't work quite yet, so I would appreciate any help (I will also ask for help on the Dlang GDC forum).

Inspiration for the flags that are set has been found in https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gdc-git .

Issues I ran into when building with nix-build -p gdc -K --cores 1:

  • When compiling without forcing --disable-shared, there are linker errors about needing to compile with -fPIC. It seems that some files are built using that flag, but not all, and I'm not sure how to go about forcing it for the rest.
  • When invoking nix-build without specifying --cores 1 there are problems when building libphobos; it looks like object files are moved before they are generated. This problem goes away when I build on a single core, but of course everything takes a very long time to try out.
  • I have disabled bootstrapping for now to speed up the debugging process, hopefully it can be enabled again later on.
  • In the current state of commit, when building with a single core, the process gets almost to the end but fails at the last part with
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/vgds3ba2r2s8fhqshqc6p0rc555fl8ns-gdc-wrapper-9.2.0
patching script interpreter paths in /nix/store/vgds3ba2r2s8fhqshqc6p0rc555fl8ns-gdc-wrapper-9.2.0
checking for references to /build/ in /nix/store/vgds3ba2r2s8fhqshqc6p0rc555fl8ns-gdc-wrapper-9.2.0...
building '/nix/store/7156ndb6f7a3jca8izbapdsmpd2v7llv-shell.drv'...
builder for '/nix/store/7156ndb6f7a3jca8izbapdsmpd2v7llv-shell.drv' failed to produce output path '/nix/store/rglh1pai765h6x1gjrrk4pbzq8vh1y09-shell'
note: keeping build directory '/tmp/nix-build-shell.drv-1'
error: build of '/nix/store/7156ndb6f7a3jca8izbapdsmpd2v7llv-shell.drv' failed
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @Synthetica

@SFrijters
Copy link
Member Author

SFrijters commented Sep 25, 2019

Well, I've made some progress:

  • I still don't know what causes libtool to misbehave in parallel, but I've forced libphobos to be built with -j1, so that's at least a working workaround that doesn't slow down the rest of the build.
  • The nixpkgs wrappers for gcc introduce the -idirafter flag, which is not accepted by gdc. It looks like this causes the check for the '-fPIC' flag to fail, and the flag to be dropped. This is the cause of the linker error for the shared libs. I've hacked around for a bit and got rid of the flag at the point of the check, so libphobos now builds correctly (but still with a bunch of warnings).
  • I've added some nix code to generate a wrapper for gdc, like the ones that are generated for the rest of the GNU compiler family.

With these changes I can now build gdc + libraries and I've successfully built the example on the dlang.org front page from a nix shell.

Does anyone know of a nicer way to get rid of the -idirafter flag, that would help a lot in cleaning up this PR.

Maybe @ThomasMader has some pointers?

@SFrijters
Copy link
Member Author

SFrijters commented Feb 28, 2020

Rebased, seems to work, but it's still a bit ugly and I don't know how to prevent all -idirafter flags, or why libphobos doesn't want to be built in parallel.

@SFrijters SFrijters force-pushed the SFrijters:gdc branch 5 times, most recently from e161628 to 933f76b Feb 28, 2020
@ofborg ofborg bot requested a review from Synthetica9 Feb 28, 2020
@OPNA2608 OPNA2608 mentioned this pull request Mar 5, 2020
10 of 46 tasks complete
@ThomasMader
Copy link
Contributor

ThomasMader commented Apr 5, 2020

I would like to see that merged into master.
GDC might be used to bootstrap LDC and for this alone it's very valuable.
I don't see any reasons why to hold this back for any longer if it is working. It can be improved over time but for now it's better to have something instead of nothing.

Can the eval errors be fixed?

Thanks a lot for your work @SFrijters.

@SFrijters
Copy link
Member Author

SFrijters commented Apr 10, 2020

I see there's merge conflicts again because this PR keeps lingering; I can probably look into it and rebase it again some time this weekend, but I would need some assistance to solve the failed evals (I think they were on platforms that are not available to me) and to get rid of the ugliness. I'm pretty much at the limit of my nix skills with this.

Edit: The failing checks I see now are different from the ones I remember. In this case I also have no idea what they mean, sad to say. Locally getting into a nix-shell works and I can still compile some randomly chosen example snippets from the D homepage.

@SFrijters SFrijters force-pushed the SFrijters:gdc branch from 933f76b to a8017d2 Apr 10, 2020
@SFrijters SFrijters changed the title WIP gdc: init at 9.2.0 WIP gdc: init at 9.3.0 Apr 17, 2020
@SFrijters SFrijters force-pushed the SFrijters:gdc branch from a8017d2 to 7e68014 Apr 22, 2020
@SFrijters
Copy link
Member Author

SFrijters commented Apr 22, 2020

I think I understand the previously failing checks now and I have rebased and fix them (I hope).
Let's see what new errors pop up. Still, locally I can build and use the compiler without apparent issues.

@ThomasMader
Copy link
Contributor

ThomasMader commented Apr 23, 2020

You are one commit behind. (8e79583#diff-a9fd46395fe31eaae37b3d89298f00cb)

Have you really rebased onto master?

@SFrijters SFrijters force-pushed the SFrijters:gdc branch from 7e68014 to 7cb693e Apr 23, 2020
@SFrijters
Copy link
Member Author

SFrijters commented Apr 23, 2020

I have, but I was unlucky and Ada has been added to gcc now too, so that was causing new merge conflicts. I think that was merged from staging to master since yesterday.

@SFrijters SFrijters force-pushed the SFrijters:gdc branch from 7cb693e to 39afc8b Apr 23, 2020
@SFrijters SFrijters changed the title WIP gdc: init at 9.3.0 gdc: init at 9.3.0 Apr 23, 2020
@ThomasMader
Copy link
Contributor

ThomasMader commented Apr 29, 2020

@worldofpeace This is also related to dlang. Can you also merge this one or is this special because it's gcc?

@worldofpeace
Copy link
Member

worldofpeace commented Apr 29, 2020

@worldofpeace This is also related to dlang. Can you also merge this one or is this special because it's gcc?

Yeah, this is special since it's a variant and we're touching cc-wrapper, which we should be careful with that. I'll see if @matthewbauer could maybe overlook it.

@SFrijters SFrijters force-pushed the SFrijters:gdc branch from 39afc8b to e345596 May 5, 2020
@SFrijters
Copy link
Member Author

SFrijters commented May 5, 2020

Rebased again, and built it using NixOS this time. I found I had to make another addition to the wrapper to make sure zlib is available when the compiler is invoked.

@ThomasMader
Copy link
Contributor

ThomasMader commented May 14, 2020

@worldofpeace The approvement by @matthewbauer was given now.

@SFrijters SFrijters force-pushed the SFrijters:gdc branch from e345596 to fc9b93d May 19, 2020
@SFrijters
Copy link
Member Author

SFrijters commented May 19, 2020

Rebased on master again to try and avoid merge conflicts later.

@SFrijters
Copy link
Member Author

SFrijters commented May 23, 2020

@Ericson2314 is there a way you could move this forward now that matthewbauer has approved this?

@matthewbauer matthewbauer merged commit c74a9cd into NixOS:master May 23, 2020
16 checks passed
16 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
gdc, gdc.passthru.tests on aarch64-linux Success
Details
gdc, gdc.passthru.tests on x86_64-linux Success
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="fc9b93d"; rev="fc9b93d2fc59dbd2bcf0777164db51c5dbf996f4"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@SFrijters
Copy link
Member Author

SFrijters commented May 23, 2020

@matthewbauer Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.