Re: [scc-dev] aarch64 support.

From: Brian Mayer <bleemayer_at_gmail.com>
Date: Sat, 9 Mar 2024 17:32:43 -0300

Hi Roberto, thanks for the quick response.

I ran make after cleaning it up and getting your commit. This time the
compilation goes further until this happens:


make[2]: Leaving directory '/home/blmayer/git/distro/scc/src'
make[1]: Leaving directory '/home/blmayer/git/distro/scc'
make[1]: Entering directory '/home/blmayer/git/distro/scc'
make[1]: *** No rule to make target 'aarch64'. Stop.
make[1]: Leaving directory '/home/blmayer/git/distro/scc'
make: *** [Makefile:18: all] Error 2

This was the Makefile in the root folder not having the aarch64
target, so I added it to the scripts/arm64.mk file which gets included
in the Makefile. Like this:

diff --git a/scripts/arm64.mk b/scripts/arm64.mk
index 949eb49b..f6ae8961 100644
--- a/scripts/arm64.mk
+++ b/scripts/arm64.mk
_at_@ -1,6 +1,9 @@
 arm64:
        +_at_$(MAKE) `$(SCRIPTDIR)/config` CONF=arm64-linux libc libcrt

+aarch64:
+ +_at_$(MAKE) `$(SCRIPTDIR)/config` CONF=arm64-linux libc libcrt
+
 install-arm64: arm64
        $(SCRIPTDIR)/install -p $(SCRIPTDIR)/proto.arm64 $(ROOT)

Not sure if this is the right choice. So running make again takes it

further but there comes a new error:

make[4]: Entering directory '/home/blmayer/git/distro/scc/src/libc/inttypes'
gcc -I../../../include -I../../../include/bits/linux
-I../../../include/bits/arm64 -I../../../include/bits/linux/arm64
-ffreestanding -fno-pie -std=c99 -fno-stack-protector -static -O1
-o imaxabs.o -c imaxabs.c
In file included from ../../../include/stdint.h:8,
                 from ../../../include/inttypes.h:4,
                 from imaxabs.c:1:
../../../include/bits/linux/arm64/arch/stdint.h:103:23: error: two or
more data types in declaration specifiers
  103 | typedef unsigned char int uint_fast8_t;
      | ^~~
../../../include/inttypes.h:5:10: fatal error: arch/inttypes.h: No
such file or directory
    5 | #include <arch/inttypes.h>
      | ^~~~~~~~~~~~~~~~~
compilation terminated.

make[4]: *** [../../../scripts/rules.mk:135: imaxabs.o] Error 1
make[4]: Leaving directory '/home/blmayer/git/distro/scc/src/libc/inttypes'
make[3]: *** [../../scripts/rules.mk:116: inttypes] Error 2
make[3]: Leaving directory '/home/blmayer/git/distro/scc/src/libc'
make[2]: *** [scripts/rules.mk:116: src/libc] Error 2
make[2]: Leaving directory '/home/blmayer/git/distro/scc'
make[1]: *** [scripts/arm64.mk:5: aarch64] Error 2
make[1]: Leaving directory '/home/blmayer/git/distro/scc'
make: *** [Makefile:18: all] Error 2

This one I tried to circumvent without success. Here's what I've done:

- Removed the int type from file
include/bits/linux/arm64/arch/stdint.h:103. Then run make again, this
error disappeared.
- Removed the arch/ from file include/inttypes.h:5, not sure if this
is specific to my system. Then run make again and a much weirder
error:

as -I../../../../include/scc longjmp.s -o longjmp.7l
as -I../../../../include/scc setjmp.s -o setjmp.7l
make[6]: Entering directory
'/home/blmayer/git/distro/scc/src/libc/arch/arm64/linux'
./gensys.sh _close
as -I../../../../../include/scc _close.s -o _close.7l
./gensys.sh _execve
as -I../../../../../include/scc _execve.s -o _execve.7l
./gensys.sh _exit
as -I../../../../../include/scc _exit.s -o _exit.7l
./gensys.sh _getpid
as -I../../../../../include/scc _getpid.s -o _getpid.7l
./gensys.sh _kill
as -I../../../../../include/scc _kill.s -o _kill.7l
./gensys.sh _lseek
as -I../../../../../include/scc _lseek.s -o _lseek.7l
./gensys.sh _openat
as -I../../../../../include/scc _openat.s -o _openat.7l
./gensys.sh _read
as -I../../../../../include/scc _read.s -o _read.7l
./gensys.sh _sigaction
as -I../../../../../include/scc _sigaction.s -o _sigaction.7l
Assembler messages:
Error: can't open _sigaction.s for reading: No such file or directory
make[6]: *** [../../../rules.mk:34: _sigaction.7l] Error 1
make[6]: Leaving directory
'/home/blmayer/git/distro/scc/src/libc/arch/arm64/linux'
make[5]: *** [../../../../scripts/rules.mk:116: linux] Error 2
make[5]: Leaving directory '/home/blmayer/git/distro/scc/src/libc/arch/arm64'
make[4]: *** [../../../scripts/rules.mk:116: arm64] Error 2
make[4]: Leaving directory '/home/blmayer/git/distro/scc/src/libc/arch'
make[3]: *** [../../scripts/rules.mk:116: arch] Error 2
make[3]: Leaving directory '/home/blmayer/git/distro/scc/src/libc'
make[2]: *** [scripts/rules.mk:116: src/libc] Error 2
make[2]: Leaving directory '/home/blmayer/git/distro/scc'
make[1]: *** [scripts/arm64.mk:5: aarch64] Error 2
make[1]: Leaving directory '/home/blmayer/git/distro/scc'
make: *** [Makefile:18: all] Error 2

Inspecting the folder containing those assembly files I see:

[blmayer_at_alarm scc]$ ls src/libc/arch/arm64/linux/
Makefile _cerrno.s _close.s _execve.s _exit.s _getpid.s
 _kill.s _lseek.s _openat.s _read.s deps.mk syscall.lst
__sigaction.s _close.7l _execve.7l _exit.7l _getpid.7l _kill.7l
 _lseek.7l _openat.7l _read.7l crt.s gensys.sh

Note that only sigaction.s has 2 "_" before it. So I removed it, by
editing the file src/libc/arch/arm64/linux/syscall.lst. This may be
some Makefile with a typo. I'm not sure if that's correct, but
compilation ran further:


make[5]: Entering directory '/home/blmayer/git/distro/scc/src/libc/arch/posix'
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o _getheap.7l -c
_getheap.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o _open.7l -c _open.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o _systime.7l -c
_systime.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o _tzone.7l -c _tzone.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o clock.7l -c clock.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o getenv.7l -c getenv.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o raise.7l -c raise.c
gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector -static -O1 -o signal.7l -c signal.c
signal.c:4:10: fatal error: arch/sigaction.h: No such file or directory
    4 | #include <arch/sigaction.h>
      | ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[5]: *** [../../../../src/libc/rules.mk:31: signal.7l] Error 1

After taking a look at:
https://pubs.opengroup.org/onlinepubs/7908799/xsh/signal.h.html. I
edited that file and changed the following:

diff --git a/src/libc/arch/posix/signal.c b/src/libc/arch/posix/signal.c
index 7bff34b0..3f04e164 100644
--- a/src/libc/arch/posix/signal.c
+++ b/src/libc/arch/posix/signal.c
_at_@ -1,8 +1,7 @@
 #include <signal.h>
 #include <stddef.h>

-#include <arch/sigaction.h>
-#include <sys.h>
+#include <signal.h>

 #undef signal

_at_@ -13,7 +12,7 @@ void
                .sa_handler = func,
        };

- if (_sigaction(signum, &sa, &osa) < 0)
+ if (sigaction(signum, &sa, &osa) < 0)
                return SIG_ERR;

        return osa.sa_handler;

Now I get the error:

make[5]: Entering directory '/home/blmayer/git/distro/scc/src/libc/arch/posix'

gcc -I../../../../include -I../../../../include/bits/linux
-I../../../../include/bits/arm64
-I../../../../include/bits/linux/arm64 -ffreestanding -fno-pie
-std=c99 -fno-stack-protector
-static -O1 -o signal.7l -c signal.c
signal.c: In function 'signal':
signal.c:12:26: error: storage size of 'osa' isn't known
   12 | struct sigaction osa, sa = {
      | ^~~
signal.c:12:16: error: variable 'sa' has initializer but incomplete type
   12 | struct sigaction osa, sa = {
      | ^~~~~~~~~
signal.c:13:18: error: 'struct sigaction' has no member named 'sa_handler'
   13 | .sa_handler = func,
      | ^~~~~~~~~~
signal.c:13:31: warning: excess elements in struct initializer
   13 | .sa_handler = func,
      | ^~~~
signal.c:13:31: note: (near initialization for 'sa')
signal.c:12:31: error: storage size of 'sa' isn't known
   12 | struct sigaction osa, sa = {
      | ^~
signal.c:16:13: warning: implicit declaration of function 'sigaction';
did you mean '_sigactio
'? [-Wimplicit-function-declaration]
   16 | if (sigaction(signum, &sa, &osa) < 0)
      | ^~~~~~~~~
      | _sigaction
make[5]: *** [../../../../src/libc/rules.mk:31: signal.7l] Error 1

That's where I stopped. Hope it helps. I don't know why the storage
size isn't known. Couldn't work this further.

Thanks.
Brian
--
To unsubscribe send a mail to scc-dev+unsubscribe_at_simple-cc.org
Received on Sat 09 Mar 2024 - 21:32:43 CET

This archive was generated by hypermail 2.3.0 : Sat 09 Mar 2024 - 21:40:36 CET