Browse Source

Hacking D

pjotrp 2 years ago
  1. 40
  2. 28


@ -1,6 +1,6 @@
* D Language support in GNU Guix
* Packaging D Language support in GNU Guix
/Fixing complicated packages with the D compiler as an example/
** Packaging ldc
@ -14,6 +14,24 @@ failing tests.
*** Building ldc compiler and phobos
Note D's ldc2 compiler now uses the gold linker by default. This has
caused me some headaches because it does not honour LIBRARY_PATH. The
workaround is to set
in the build system. This can be done with something like
: (setenv "LD_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
only problem is that the path won't get recognized at runtime. This
is why I am defaulting to ld for now.
Also it may be wise with gold to default to the
--no-allow-shlib-undefined switch, so it complains when it can't find
a shared library at link time.
Build the package with -K option.
@ -70,13 +88,29 @@ in all build dependencies)
~/.config/guix/current/bin/guix environment -C guix --ad-hoc ldc clang llvm unzip gdb ncurses vim git make cmake which less tzdata binutils
cd ldc-$ver
source ./environment-variables
rm -rf CMakeFiles CMakeCache.txt
cmake .
make clean
make -j 24
to run the tests
alternatively, you may use the pre-inst-env from a prebuilt guix directory which may be in sync with
your new packages.
Note with ldc-1.14 I had to touch two files:
touch /tmp/guix-build-ldc-1.14.0.drv-8/ldc-1.14.0/.git/packed-refs
touch /tmp/guix-build-ldc-1.14.0.drv-8/ldc-1.14.0/CMakeFiles/git-data/head-ref
which makes sure cmake . passes.
and I had to set LD_LIBRARY_PATH to point to the LLVM lib dir. Somehow
that was not the same one used by the build system.
To run the tests
: cmake .


@ -1013,6 +1013,8 @@ not get applied. In this case comment out
And rerun the Error log to get a full list of errors.
**** Force a build to stop
You may also want to force the build to stop right after unpacking by
@ -1030,6 +1032,18 @@ Now the build will fail with
: ERROR: In procedure #f:
: note: keeping build directory `/tmp/guix-build-elixir-1.5.1.drv-5'
Another option is to inject (#f)
#+BEGIN_SRC scheme
(replace 'build
(lambda _
(invoke "bash" "-c" "set")
(invoke "./")))
will halt after showing the environment
*** Use git to create a patch
Initialize git using a first terminal
@ -1365,6 +1379,20 @@ If that does not work you can also run a command that fails, such as
(chdir "END HERE")
*** Show environment settings
Another useful hack is to show the environment
#+BEGIN_SRC scheme
(replace 'build
(lambda _
(setenv "LD_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
(invoke "bash" "-c" "set")
(invoke "./")))
** Using -K (keep build) to create a patch
Using -K you can keep the build dir after failure (induced in above