racket / ChezScheme

Chez Scheme
Apache License 2.0
110 stars 8 forks source link

PinePhone (aarch64): building fails with arm32le.c:60:38: error: '_SC_LEVEL1_DCACHE_LINESIZE' undeclared (first use in this function) #40

Closed ecraven closed 3 years ago

ecraven commented 3 years ago

When trying to build on a PinePhone (via pb), I run into the following error:

Configuring for tarm64le
pine64-pinephone:~/ChezScheme$ make
(cd tarm64le && make build)
(cd c && make)
ln -s "../../."/c/statics.c statics.c
ln -s "../../."/c/system.h system.h
ln -s "../../."/c/types.h types.h
ln -s "../../."/c/version.h version.h
ln -s "../../."/c/externs.h externs.h
ln -s "../../."/c/globals.h globals.h
ln -s "../../."/c/segment.h segment.h
ln -s "../../."/c/atomic.h atomic.h
ln -s "../../."/c/thread.h thread.h
ln -s "../../."/c/sort.h sort.h
ln -s "../../."/c/compress-io.h compress-io.h
ln -s "../../."/c/nocurses.h nocurses.h
ln -s "../../."/c/popcount.h popcount.h
(cd ../zlib; CC="gcc" CPPFLAGS="" AR="ar" ARFLAGS="rc" RANLIB="ranlib" CFLAGS="-D_REENTRANT -pthread" LDFLAGS="-rdynamic" ./configure )
Checking for shared library support...
Building shared library libz.so.1.2.11 with gcc.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  statics.c
ln -s "../../."/c/segment.c segment.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  segment.c
ln -s "../../."/c/alloc.c alloc.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  alloc.c
ln -s "../../."/c/symbol.c symbol.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  symbol.c
ln -s "../../."/c/intern.c intern.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  intern.c
ln -s "../../."/c/gcwrapper.c gcwrapper.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  gcwrapper.c
ln -s "../../."/c/gc-011.c gc-011.c
ln -s "../../."/c/gc.c gc.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  gc-011.c
ln -s "../../."/c/gc-par.c gc-par.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  gc-par.c
ln -s "../../."/c/gc-ocd.c gc-ocd.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  gc-ocd.c
ln -s "../../."/c/gc-oce.c gc-oce.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  gc-oce.c
ln -s "../../."/c/number.c number.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  number.c
ln -s "../../."/c/schsig.c schsig.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  schsig.c
ln -s "../../."/c/io.c io.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  io.c
ln -s "../../."/c/new-io.c new-io.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  new-io.c
ln -s "../../."/c/print.c print.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  print.c
ln -s "../../."/c/fasl.c fasl.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  fasl.c
ln -s "../../."/c/vfasl.c vfasl.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  vfasl.c
ln -s "../../."/c/stats.c stats.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  stats.c
ln -s "../../."/c/foreign.c foreign.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  foreign.c
ln -s "../../."/c/prim.c prim.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  prim.c
ln -s "../../."/c/prim5.c prim5.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  prim5.c
ln -s "../../."/c/flushcache.c flushcache.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  flushcache.c
ln -s "../../."/c/schlib.c schlib.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  schlib.c
ln -s "../../."/c/thread.c thread.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  thread.c
ln -s "../../."/c/expeditor.c expeditor.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  expeditor.c
ln -s "../../."/c/scheme.c scheme.c
ln -s "../../."/c/itest.c itest.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  scheme.c
ln -s "../../."/c/compress-io.c compress-io.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  compress-io.c
ln -s "../../."/c/random.c random.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  random.c
ln -s "../../."/c/arm32le.c arm32le.c
gcc  -D_REENTRANT -pthread -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -c  -DAARCH64 -I../boot/tarm64le -I../zlib -I../lz4/lib  arm32le.c
arm32le.c: In function 'S_machine_init':
arm32le.c:60:38: error: '_SC_LEVEL1_DCACHE_LINESIZE' undeclared (first use in this function)
   60 |   if ((l1_dcache_line_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)) <= 0) {
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
arm32le.c:60:38: note: each undeclared identifier is reported only once for each function it appears in
arm32le.c:63:38: error: '_SC_LEVEL1_ICACHE_LINESIZE' undeclared (first use in this function)
   63 |   if ((l1_icache_line_size = sysconf(_SC_LEVEL1_ICACHE_LINESIZE)) <= 0) {
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:9: arm32le.o] Error 1
make[1]: *** [Makefile:21: build] Error 2
make: *** [Makefile:20: build] Error 2

The PinePhone distro I use is built on alpine, which uses musl instead of glibc, might that be related to this problem?

Thanks for any help with this, it would be great to get chez (and by extension racket) running on the PinePhone!

samth commented 3 years ago

This looks related: https://github.com/atheme/libmowgli-2/issues/43

mflatt commented 3 years ago

Yes, that makes sense. For now, I think you should be able to change #if defined(__linux__) in "arm32le.c" to #if 0.

ecraven commented 3 years ago

Thanks, I'll try that as soon as I can and report back!

mflatt commented 3 years ago

I pushed a change that I think should fix the problem, but forgot to mention this issue: 09b8c823e21c0359cf1e2d677a65de632340f27e

ecraven commented 3 years ago

I don't see your commit in this repo, but I've just added && defined(_SC_LEVEL1_ICACHE_LINESIZE), which enables the compilation to run successfully. I haven't tried to run many programs, but chez starts up fine ;) Thanks for the help, I'll play around with this further, and maybe try to actually build racket on the PinePhone (which is very slow at building :-/). One of these days I should look into how to cross-compile things here..