From d64d09d995d7d55e47cc8553f2ec59c32dae0e66 Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Sat, 12 Oct 2024 11:13:38 -0300 Subject: [PATCH 1/4] Use $STKLOS_BINARY, not src/stklos during compilation This is a very small change, but is crucial for cross-compilation. When the variable `STKLOS_BINARY` is set, it will be used (during cross-compilation, it will be the locally installed stklos); when it is not set, then `${prefix}/src/stklos` is used. Also: - In tmpcomp, the prefix was computed as `../`, relative to utils. But in tmpgenlex it was hardcoded. This also changes tmpgenlex to do the same as tmpcomp --- utils/tmpcomp | 4 +++- utils/tmpgenlex | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/tmpcomp b/utils/tmpcomp index 0ddfe6a54..f1c7c7011 100755 --- a/utils/tmpcomp +++ b/utils/tmpcomp @@ -62,12 +62,14 @@ case $# in esac prefix="$(cd -- "$(dirname "$0")/.." >/dev/null 2>&1 && pwd)" +[ "x$STKLOS_BINARY" != "x" ] || STKLOS_BINARY=${prefix}/src/stklos STKLOS_LOAD_PATH=".:../lib:${prefix}/lib:" STKLOS_BUILDING=1 export STKLOS_LOAD_PATH STKLOS_BUILDING -${prefix}/src/stklos -c -q -f ${prefix}/utils/stklos-compile.stk -- \ + +${STKLOS_BINARY} -c -q -f ${prefix}/utils/stklos-compile.stk -- \ --no-time $Copt --output=$out $in status=$? diff --git a/utils/tmpgenlex b/utils/tmpgenlex index e5b5f4104..4579f32a2 100755 --- a/utils/tmpgenlex +++ b/utils/tmpgenlex @@ -24,10 +24,11 @@ # Creation date: 1-Jan-2002 18:57 (eg) # +prefix="$(cd -- "$(dirname "$0")/.." >/dev/null 2>&1 && pwd)" +[ "x$STKLOS_BINARY" != "x" ] || STKLOS_BINARY=${prefix}/src/stklos -STKLOS_LOAD_PATH="../lib" -export STKLOS_LOAD_PATH - -../src/stklos -c -q -b ../src/boot.img -f ../utils/stklos-genlex -- $* +STKLOS_LOAD_PATH=".:../lib:${prefix}/lib:" +export STKLOS_LOAD_PATH +${STKLOS_BINARY} -c -q -b ../src/boot.img -f ../utils/stklos-genlex -- $* From bd220b3c104f36ae17c506476586f0826f374099 Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Sun, 13 Oct 2024 21:43:18 -0300 Subject: [PATCH 2/4] Don't use $@ when calling make recursively This seems to break cross-copilation. The program `tmpcomp` uses the environment variable STKLOS_BINARY to tell which STklos executable it can use. However, when we use this rule: ``` ../streams/derived.ostk: ../streams/primitive.ostk: (cd ../streams && $(MAKE) $@) ``` that varible is not passed recursively to the child make, and the process fails during cross-compilation. If we do this: ``` ../streams/derived.ostk: (cd ../streams && $(MAKE) derived.ostk) ../streams/primitive.ostk: (cd ../streams && $(MAKE) primitive.ostk) ``` it (magically?) works. --- lib/scheme/Makefile.am | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/scheme/Makefile.am b/lib/scheme/Makefile.am index 9cbaaba73..e23c651ff 100644 --- a/lib/scheme/Makefile.am +++ b/lib/scheme/Makefile.am @@ -151,8 +151,11 @@ SUFFIXES = .stk .ostk .stk -incl.c .$(SO) .c stream.ostk: ../streams/primitive.ostk ../streams/derived.ostk -../streams/derived.ostk ../streams/primitive.ostk: - (cd ../streams && $(MAKE) $@) +../streams/derived.ostk: + (cd ../streams && $(MAKE) derived.ostk) + +../streams/primitive.ostk: + (cd ../streams && $(MAKE) primitive.ostk) set.ostk: ../srfi/69.ostk comparator.ostk From 52cc8414a7bdaea16bcd6bd58e42e31429ae52b6 Mon Sep 17 00:00:00 2001 From: Jeronimo Pellegrini Date: Mon, 14 Oct 2024 07:00:39 -0300 Subject: [PATCH 3/4] Add short instructions for cross-compilation --- INSTALL-cross-compile.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 INSTALL-cross-compile.md diff --git a/INSTALL-cross-compile.md b/INSTALL-cross-compile.md new file mode 100644 index 000000000..2f157edce --- /dev/null +++ b/INSTALL-cross-compile.md @@ -0,0 +1,36 @@ +# Cross-compiling STklos + +## How to cross-compile + +Cross-compilation is just like compilation + +``` +./configure prefix=some-tmp-dir CC=some-C-compiler CFLAGS=your-c-flags ... +make +make install +``` + +The relevant environment variables are described in the output +of `configure --help`. + +***However:*** + +* You *need* a STklos binary in order to compile STklos. When not + cross-copiling, + - the binary is generated as `src/stklos` + - the build proceeds using `src/stklos` as the STklos binary that + can be used to compile `.stk` files + However, when cross-compiling `src/stklos` will be a binary for a + different (target) architecture, and the build will fail, unless we + have a native STklos in the system that can be used instead. + +* Put the full path of the STklos binary in the `STKLOS_BINARY` + variable when calling `make`: + +``` +./configure --prefix=/usr/some/place +make `STKLOS_BINARY=/usr/local/bin/stklos` +make install +``` + +Now you can copy the `usr/some/place` directory to the target machine. From d7aaacced367f7bbf1cdab86c7720f81db8ca025 Mon Sep 17 00:00:00 2001 From: Erick Gallesio Date: Mon, 14 Oct 2024 19:50:57 +0200 Subject: [PATCH 4/4] Typo --- INSTALL-cross-compile.md | 2 +- lib/scheme/Makefile.in | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/INSTALL-cross-compile.md b/INSTALL-cross-compile.md index 2f157edce..11e376e05 100644 --- a/INSTALL-cross-compile.md +++ b/INSTALL-cross-compile.md @@ -16,7 +16,7 @@ of `configure --help`. ***However:*** * You *need* a STklos binary in order to compile STklos. When not - cross-copiling, + cross-compiling, - the binary is generated as `src/stklos` - the build proceeds using `src/stklos` as the STklos binary that can be used to compile `.stk` files diff --git a/lib/scheme/Makefile.in b/lib/scheme/Makefile.in index c699179e3..6a289b5d8 100644 --- a/lib/scheme/Makefile.in +++ b/lib/scheme/Makefile.in @@ -875,8 +875,11 @@ STKLOS_BINARY ?= ../../src/stklos stream.ostk: ../streams/primitive.ostk ../streams/derived.ostk -../streams/derived.ostk ../streams/primitive.ostk: - (cd ../streams && $(MAKE) $@) +../streams/derived.ostk: + (cd ../streams && $(MAKE) derived.ostk) + +../streams/primitive.ostk: + (cd ../streams && $(MAKE) primitive.ostk) set.ostk: ../srfi/69.ostk comparator.ostk