[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Packaging the GNU Modula 2 compiler
From: |
Holger Peters |
Subject: |
Packaging the GNU Modula 2 compiler |
Date: |
Sun, 03 Jan 2021 16:11:00 +0100 |
User-agent: |
Evolution 3.38.2-1 |
I have trouble building the GNU Modula 2 compiler
[[https://www.nongnu.org/gm2/][GNU Modula 2 compiler]]. And I think I
could use some help with that.
tl;dr: After packaging the GNU Modula 2 compiler with guix I get an
error about: '/usr/bin/ld: cannot find crt1.o: No such file or
directory'
The information on building it is a bit sparse. Here is what I could
gather.
* I managed to get a successful build of `gm2', that would compile
modula files to *.o files. However, I wasn't able to link to an
executable due to multilib issues (see below).
* It seems there are no (recent) source releases for GNU Modula 2,
the expecation is to get the releases from the git repository.
* GNU Modula 2 is a gcc-based compiler.
* The latest stable release of gm2 is based on gcc-10.
[[https://www.nongnu.org/gm2/building.html][Source]]
* Build guidelines are available under
[[https://www.nongnu.org/gm2/building_on_gcc_10.html][Building GNU
Modula-2 grafted on the
gcc-10 branch]].
As per the docs, these are the recommended configuration steps. You'll
see that my guix package definition below differs in detail.
#+BEGIN_SRC sh
git clone http://floppsie.comp.glam.ac.uk/gm2 gm2-floppsie
cd gm2-floppsie
git checkout gm2-10
./contrib/download_prerequisites
cd ../..
sudo apt-get install gcc-multilib libmpfr-dev libgmp-dev libmpc-dev
flex
mkdir build-gcc-10
cd build-gcc-10
CXXFLAGS=-g BOOT_CFLAGS=-g CFLAGS=-g \
../gm2-floppsie/configure \
--prefix=$HOME/opt \
--libexecdir=$HOME/opt/lib \
--enable-threads=posix \
--enable-clocale=gnu --enable-languages=c,c++,m2 \
--disable-multilib --disable-bootstrap --enable-checking
#+END_SRC
* Questions
** Linking Issue / Multilib
There is a /multilib/ configuration flag (disable/enable) and for the
apt-based distros it seems GM2 devs recommend the installation of
gcc-multilib. Since I don't find a multilib package in guix, I think
the approach might be a little different for guix. What needs to be
done here?
I did leave /--disable-multilib/ in the configure flags in my build
recipe below. Then when compiling a source file like this
[[https://www.nongnu.org/gm2/example_usage.html][Source]]
#+BEGIN_SRC modula-2
MODULE hello;
FROM StrIO IMPORT WriteString, WriteLn ;
BEGIN
WriteString('hello world') ; WriteLn
END hello.
#+END_SRC
I get the following error (`gm2 -v -g hello.mod'):
#+BEGIN_SRC text
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
#+END_SRC
(Full verbose log in attached file `out.log').
** /usr/bin/ld
Shouldn't I expect - in the error message - to see a reference to ld as
provided by guix?
** Outputs
This is a bit of a follow-up question. I had more success building GM2
with the GCC bootstrapping enabled. I think the build outputs should
be restricted when going down that path. How do I make sure that the
`gcc' executables aren't propagated into the PATH when installing gm2.
* Build recipe
This is what I camee up with so far. I realize this isn't a /polished/
patch yet, my focus is to get it to build.
#+BEGIN_SRC scheme
(define-module (yas packages gm2)
#:use-module (gnu packages gcc)
#:use-module (gnu packages flex)
#:use-module (gnu packages bison)
#:use-module (gnu packages python)
#:use-module (guix search-paths)
#:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix packages)
#:use-module (guix build-system gnu)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 regex))
(define %generic-search-paths
;; This is the language-neutral search path for GCC. Entries in
$CPATH are
;; not considered "system headers", which means GCC can raise
warnings for
;; issues in those headers. 'CPATH' is the only one that works for
;; front-ends not in the C family.
(list (search-path-specification
(variable "CPATH")
(files '("include")))
(search-path-specification
(variable "LIBRARY_PATH")
(files '("lib" "lib64")))))
(define-public gm2
(let ((revision "3")
(commit "5f55e3e8a7bd2142eff043479c4059242e81e2ea")
(git-url "http://floppsie.comp.glam.ac.uk/gm2")
(name "gm2")
(version "gm2-10"))
(package (inherit gcc-10)
(name name)
(version version)
(source (origin
(method git-fetch)
(uri (git-reference
(url git-url)
(commit commit)))
(file-name (git-file-name name version))
(sha256 (base32
"0cc46bkv198j7hn1ihczf6p4fpby3cnp57rml679rna2cmhzhp4x"))))
(native-search-paths %generic-search-paths)
(properties (alist-delete 'hidden? (package-properties
gcc)))
(native-inputs
(append `(("bison" ,bison)
("flex" ,flex)
("python3" ,python)
)
(package-native-inputs gcc-10)))
(arguments
(substitute-keyword-arguments (package-arguments gcc)
((#:modules modules %gnu-build-system-modules)
`(,@modules
(srfi srfi-1)
(srfi srfi-26)
(ice-9 regex)))
((#:configure-flags flags)
(let* ((gm2-flags '(list
"--enable-languages=m2"
;; "--enable-languages=c,c++,m2"
;; "--disable-bootstrap"
;; "--disable-multilib"
"--enable-checking"
"--enable-threads=posix"))
(tail `(remove (cut string-match "--enable-
languages.*" <>)
,flags)))
`(append ,gm2-flags ,tail)))
((#:phases phases)
`(modify-phases ,phases
(add-after 'install 'remove-broken-or-
conflicting-files
(lambda* (#:key outputs #:allow-other-keys)
(for-each delete-file
(find-files (string-append (assoc-
ref outputs "out") "/bin")
".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
#true))))))
(synopsis "modula2 compiler")
(description "modula2 compiler"))))
#+END_SRC
out.log
Description: Text Data
signature.asc
Description: This is a digitally signed message part
- Packaging the GNU Modula 2 compiler,
Holger Peters <=