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

Cross-compilation fails due to target-built tools being run during build #205

Open
sin-ack opened this issue Jan 4, 2025 · 1 comment
Open

Comments

@sin-ack
Copy link

sin-ack commented Jan 4, 2025

When trying to cross-compile snowball, I hit the following issue:

make -j24 
libstemmer/mkalgorithms.pl algorithms.mk libstemmer/modules.txt
sed 's/@MODULES_H@/modules.h/' libstemmer/libstemmer_c.in >libstemmer/libstemmer.c
libstemmer/mkmodules.pl libstemmer/modules.h src_c libstemmer/modules.txt libstemmer/mkinc.mak
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o runtime/api.o runtime/api.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations -Iinclude  -c -o examples/stemwords.o examples/stemwords.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/driver.o compiler/driver.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/space.o compiler/space.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o runtime/utilities.o runtime/utilities.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/tokeniser.o compiler/tokeniser.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_python.o compiler/generator_python.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_csharp.o compiler/generator_csharp.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_rust.o compiler/generator_rust.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_go.o compiler/generator_go.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator.o compiler/generator.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_pascal.o compiler/generator_pascal.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_ada.o compiler/generator_ada.c
In function ‘generate_try’,
    inlined from ‘generate.part.0’ at compiler/generator_ada.c:1325:31:
compiler/generator_ada.c:462:9: warning: ‘savevar’ may be used uninitialized [-Wmaybe-uninitialized]
  462 |         str_delete(savevar);
      |         ^~~~~~~~~~~~~~~~~~~
compiler/generator_ada.c: In function ‘generate.part.0’:
compiler/generator_ada.c:442:18: note: ‘savevar’ was declared here
  442 |     struct str * savevar;
      |                  ^~~~~~~
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_js.o compiler/generator_js.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/generator_java.o compiler/generator_java.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations   -c -o compiler/analyser.o compiler/analyser.c
riscv64-unknown-linux-gnu-gcc -O2 -pipe -fomit-frame-pointer -fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations  -o snowball compiler/space.o compiler/tokeniser.o compiler/analyser.o compiler/generator.o compiler/driver.o compiler/generator_csharp.o compiler/generator_java.o compiler/generator_js.o compiler/generator_pascal.o compiler/generator_python.o compiler/generator_rust.o compiler/generator_go.o compiler/generator_ada.o
./snowball algorithms/arabic.sbl -o src_c/stem_UTF_8_arabic -eprefix arabic_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_arabic.h] Error 126
make: *** Waiting for unfinished jobs....
./snowball algorithms/armenian.sbl -o src_c/stem_UTF_8_armenian -eprefix armenian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_armenian.h] Error 126
./snowball algorithms/basque.sbl -o src_c/stem_UTF_8_basque -eprefix basque_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_basque.h] Error 126
./snowball algorithms/catalan.sbl -o src_c/stem_UTF_8_catalan -eprefix catalan_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_catalan.h] Error 126
./snowball algorithms/danish.sbl -o src_c/stem_UTF_8_danish -eprefix danish_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_danish.h] Error 126
./snowball algorithms/dutch.sbl -o src_c/stem_UTF_8_dutch -eprefix dutch_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_dutch.h] Error 126
./snowball algorithms/english.sbl -o src_c/stem_UTF_8_english -eprefix english_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_english.h] Error 126
./snowball algorithms/finnish.sbl -o src_c/stem_UTF_8_finnish -eprefix finnish_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_finnish.h] Error 126
./snowball algorithms/french.sbl -o src_c/stem_UTF_8_french -eprefix french_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_french.h] Error 126
./snowball algorithms/german.sbl -o src_c/stem_UTF_8_german -eprefix german_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_german.h] Error 126
./snowball algorithms/greek.sbl -o src_c/stem_UTF_8_greek -eprefix greek_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_greek.h] Error 126
./snowball algorithms/hungarian.sbl -o src_c/stem_UTF_8_hungarian -eprefix hungarian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_hungarian.h] Error 126
./snowball algorithms/hindi.sbl -o src_c/stem_UTF_8_hindi -eprefix hindi_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_hindi.h] Error 126
./snowball algorithms/indonesian.sbl -o src_c/stem_UTF_8_indonesian -eprefix indonesian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_indonesian.h] Error 126
./snowball algorithms/irish.sbl -o src_c/stem_UTF_8_irish -eprefix irish_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_irish.h] Error 126
./snowball algorithms/italian.sbl -o src_c/stem_UTF_8_italian -eprefix italian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_italian.h] Error 126
./snowball algorithms/nepali.sbl -o src_c/stem_UTF_8_nepali -eprefix nepali_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_nepali.h] Error 126
./snowball algorithms/lithuanian.sbl -o src_c/stem_UTF_8_lithuanian -eprefix lithuanian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_lithuanian.h] Error 126
./snowball algorithms/norwegian.sbl -o src_c/stem_UTF_8_norwegian -eprefix norwegian_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_norwegian.h] Error 126
./snowball algorithms/porter.sbl -o src_c/stem_UTF_8_porter -eprefix porter_UTF_8_ -r ../runtime -u
/bin/sh: line 4: ./snowball: cannot execute binary file: Exec format error
make: *** [GNUmakefile:258: src_c/stem_UTF_8_porter.h] Error 126

The problem is that the snowball tool is being compiled with riscv64-unknown-linux-gnu-gcc which is my cross-compiler, but the tool is run at build time, so it should be built with the host compiler. There should be separate HOST and TARGET variables which can be set on the Makefile with which the correct compiler will be used ($(HOST)-cc and so on).

@thesamesam
Copy link

It should be BUILD and HOST, I think.

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

No branches or pull requests

2 participants