===TLDR added at end of this experience===Go to post #10 for the final result of the particular use case: CoreUtils
Go to post #14 for the questions that I formed after this whole experience.
===Start of original post======Goal===Cross compile and build CoreUtils on an x86 for use on my Amiga X1000 OS 4 FE U2.
===Some Info===I will not post all commands in here, some obvious ones like copying directories I will ommit. The reason for posting all of this information is purely because of my own experiences: I hate it when searching for information and coming across a potentially great thread that does not contain enough information.
I also create this quasi-step-by-step guide because someone will probably go: NO! Don't do it like that! For example, I may be using an out-of-date guide or using a git-hub location that is way out of date, or, just doing something plain-wrong!
Lines that begin with "PRESUMPTION:" document my thought process and general questions.
===Host Machine===
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 36 bits physical, 48 bits virtual
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 23
Model name: Genuine Intel(R) CPU U4100 @ 1.30GHz
Stepping: 10
CPU MHz: 1200.000
CPU max MHz: 1300.0000
CPU min MHz: 1200.0000
BogoMIPS: 2593.26
L1d cache: 64 KiB
L1i cache: 64 KiB
L2 cache: 2 MiB
NUMA node0 CPU(s): 0,1
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no mic
rocode; SMT disabled
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user
pointer sanitization
Vulnerability Spectre v2: Mitigation; Full generic retpoline, STIBP disab
led, RSB filling
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtr
r pge mca cmov pat pse36 clflush dts acpi mmx f
xsr sse sse2 ht tm pbe syscall nx lm constant_t
sc arch_perfmon pebs bts rep_good nopl cpuid ap
erfmperf pni dtes64 monitor ds_cpl est tm2 ssse
3 cx16 xtpr pdcm xsave lahf_lm pti dtherm
===Host OS===
Linux rjd-Aspire-5810T 5.11.0-43-generic #47~20.04.2-Ubuntu SMP Mon Dec 13 11:06:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
---
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
===Source Code for CoreUtils===https://github.com/adtools/coreutils===Guide(s) I am using for my goal===I am really only using README.os4 / README and browsing the configure file to glean information.
===Start Doing Things===I am going to create a CHROOT using Xenial 32-bit because we want to use 32-lib libraries and it comes with GCC version 5.X***; all the packages mentioned as requisites for compiling the cross tool chain match up with Xenial. I do not want to mess around with multi-arch etc and having a CHROOT seems a lot cleaner. It has been a long time since I did this, so there maybe easier or better methods.
*** - I mention this because I need to compile the cross-compiler toolchain, and the prerequisites mentions a need for GCC 5.X 32-bit.
===CHROOT a Xenial 32-bit===I will create a directory: /var/2xenial32 which will be the root for the 32-bit Xenial.
I will use debootstrap to create a minimal image:
debootstrap --variant=buildd --arch i386 xenial /var/chroot/2xenial32/ http://archive.ubuntu.com/ubuntu/
Copy the apt/sources and rename focal to xenial so that I can access the right repos for packages.
===Okay, now I need to get a cross compiler before building CoreUtils===I will use:
https://github.com/adtools/amigaos-cross-toolchainAnd the guide for that:
https://github.com/adtools/amigaos-cro ... ain/blob/master/README.md.
We will create the gcc 4.2.4 cross-compiler for OS 4 FE U2.
Let me CHROOT into the 2xenial32 and start building the cross toolchain. Before I can even start, let's get all the prerequisites in the README.md file. This is essentially running apt-get install for each of these packages. It also includes running install for a few other packages that are not mentioned in the README file that must have been left out by mistake; I needed to also install subversion and flex.
Also, during step 2 of the README.md:
./toolchain-ppc --prefix=/opt/ppc-amigaos build
the script (toolchain-ppc) will hang when trying to download
http://isl.gforge.inria.fr/isl-0.12.2.tar.bz2 because this file no longer exists. So, I just searched for it and hacked in a new url.
Then, I run: ./toolchain-ppc --prefix=/opt/ppc-amigaos build
and wait for a long time, since the host machine is real slow!
And, when it is finished I test the default paths etc for the compiler:
$> ./ppc-amigaos-gcc -xc -E -v -
Using built-in specs.
Target: ppc-amigaos
Configured with: /home/Amiga/amigaos-cross-toolchain/.build-ppc/archives/gcc-4.2.4/configure --prefix=/opt/ppc-amigaos --target=ppc-amigaos --with-bugurl=http://sf.net/p/adtools --with-gmp=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-mpfr=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-isl=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-cloog=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --enable-languages=c,c++ --enable-haifa --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-tls
Thread model: single
gcc version 4.2.4 (adtools build 20100512)
/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/cc1 -E -quiet -v -mcrt=newlib -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/local/newlib/include -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/include/include_h -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/include/netinclude -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/local/common/include -
ignoring nonexistent directory "/opt/ppc-amigaos/ppc-amigaos/SDK/local/newlib/include"
ignoring nonexistent directory "/opt/ppc-amigaos/ppc-amigaos/SDK/local/common/include"
ignoring nonexistent directory "/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include
/opt/ppc-amigaos/ppc-amigaos/SDK/include/include_h
/opt/ppc-amigaos/ppc-amigaos/SDK/include/netinclude
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/include
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/include
End of search list.
And, to test with -mcrt=clib2:
$> ./ppc-amigaos-gcc -xc -E -v -mcrt=clib2 -
Using built-in specs.
Target: ppc-amigaos
Configured with: /home/Amiga/amigaos-cross-toolchain/.build-ppc/archives/gcc-4.2.4/configure --prefix=/opt/ppc-amigaos --target=ppc-amigaos --with-bugurl=http://sf.net/p/adtools --with-gmp=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-mpfr=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-isl=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --with-cloog=/home/Amiga/amigaos-cross-toolchain/.build-ppc/host --enable-languages=c,c++ --enable-haifa --enable-sjlj-exceptions --disable-libstdcxx-pch --disable-tls
Thread model: single
gcc version 4.2.4 (adtools build 20100512)
/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/cc1 -E -quiet -v -imultilib clib2 -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/local/clib2/include -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/include/include_h -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/include/netinclude -isystem /opt/ppc-amigaos/ppc-amigaos/SDK/local/common/include - -mcrt=clib2
ignoring nonexistent directory "/opt/ppc-amigaos/ppc-amigaos/SDK/local/clib2/include"
ignoring nonexistent directory "/opt/ppc-amigaos/ppc-amigaos/SDK/local/common/include"
ignoring nonexistent directory "/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include
/opt/ppc-amigaos/ppc-amigaos/SDK/include/include_h
/opt/ppc-amigaos/ppc-amigaos/SDK/include/netinclude
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/include
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/include
End of search list.
And:
$> ./ppc-amigaos-gcc -print-search-dirs
install: /opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/
programs: =/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/:/usr/libexec/gcc/ppc-amigaos/4.2.4/:/usr/libexec/gcc/ppc-amigaos/:/usr/lib/gcc/ppc-amigaos/4.2.4/:/usr/lib/gcc/ppc-amigaos/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/bin/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/bin/
libraries: =/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/:/usr/lib/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/
And, for -mcrt=clib2:
./ppc-amigaos-gcc -mcrt=clib2 -print-search-dirs
install: /opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/
programs: =/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/libexec/gcc/ppc-amigaos/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/:/usr/libexec/gcc/ppc-amigaos/4.2.4/:/usr/libexec/gcc/ppc-amigaos/:/usr/lib/gcc/ppc-amigaos/4.2.4/:/usr/lib/gcc/ppc-amigaos/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/bin/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/bin/
libraries: =/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/clib2/:/usr/lib/gcc/ppc-amigaos/4.2.4/clib2/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/ppc-amigaos/4.2.4/clib2/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/clib2/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/:/usr/lib/gcc/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/ppc-amigaos/4.2.4/:/opt/ppc-amigaos/lib/gcc/ppc-amigaos/4.2.4/../../../../ppc-amigaos/lib/
===Peforming a basic test of hello world===As the heading suggest, I now create a simple application printing out hello world, scp to amiga and run it to ensure that it works so far.
Since the compiler defaults to newlib I compile helloWorld both by default and by appending -mcrt=clib2.
Both binaries work.
===Get back to building CoreUtils===Since the README.os4 for CoreUtils says:
Quote:
06-08-2017 - Version 54.1
Coreutils 8.29 source used for the port
The sourcecode for Sort and Split have been replaced with the old 5.2.1-9 code.
To compile you need libwide found on http://os4depot.net and the current clib2 code from http://github.com/adtools/clib2
I should probably get libwide and the "current" clib2 from the github. So, let's do that.
===libwide===Just extract it into the SDK directory.
===clib2===The issue is that for the documentation readme file for building
http://github.com/adtools/clib2 says:
Quote:
In order to build the library, you need a 'C' compiler (obvious, isn't it?) and a set of header files for the networking API definitions. The networking header files go into a directory netinclude which has to sit in the same directory as the source code and the include directory you find in there. I'm not currently supplying these header files here. Drop me a line, and I'll take care of that.
So, I am not sure how to get the "netinclude".
Quote:
PRESUMPTION: let's just see if the CLIB created by the X-toolchain works.
===start compiling CoreUtils===Since the default for the X-compiler is not to use CLIB, I am assuming I need to override that and add CFLAGS=-mcrt=clib2 as well as set the --host=ppc-amigaos. The X-compiler needs to be on the path also!
Quote:
PRESUMPTION: Should I add -lwide? For now, I am not.
But, just to see what happens I try:
./configure --host=ppc-amigaos
And this generates okay, but when I try
make
I get:
make[2]: Entering directory '/home/Amiga/coreutils-master'
CC lib/copy-acl.o
In file included from /opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include/sys/select.h:7,
from ./lib/sys/select.h:100,
from /opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include/sys/time.h:16,
from ./lib/sys/time.h:39,
from ./lib/sys/resource.h:30,
from /opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include/sys/reent.h:19,
from /opt/ppc-amigaos/ppc-amigaos/SDK/newlib/include/time.h:11,
from ./lib/time.h:41,
from ./lib/sys/stat.h:44,
from lib/acl.h:25,
from lib/copy-acl.c:22:
./lib/signal.h:578: error: expected identifier or '(' before 'const'
./lib/signal.h:578: error: expected ')' before '&' token
./lib/signal.h:578: error: expected ')' before '!=' token
./lib/signal.h:591: error: expected ')' before '*' token
./lib/signal.h:591: error: expected ')' before '=' token
./lib/signal.h:603: error: expected ')' before '*' token
./lib/signal.h:603: error: expected ')' before '|=' token
./lib/signal.h:616: error: expected ')' before '*' token
./lib/signal.h:616: error: expected ')' before '&=' token
./lib/signal.h:629: error: expected ')' before '*' token
./lib/signal.h:629: error: expected ')' before '=' token
In file included from ./lib/sys/stat.h:44,
from lib/acl.h:25,
from lib/copy-acl.c:22:
./lib/time.h:482:6: error: token "@" is not valid in preprocessor expressions
./lib/time.h:568:6: error: token "@" is not valid in preprocessor expressions
./lib/time.h:618:6: error: token "@" is not valid in preprocessor expressions
./lib/time.h:636:6: error: token "@" is not valid in preprocessor expressions
And, when you look at that line you can see:
#if !(defined __amigaos__ && defined __CLIB2__) /* AmigaOS using CLIB2 */
/* Initialize time conversion information. */
# if @GNULIB_TZSET@
# if @REPLACE_TZSET@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef tzset
# define tzset rpl_tzset
# endif
_GL_FUNCDECL_RPL (tzset, void, (void));
_GL_CXXALIAS_RPL (tzset, void, (void));
# else
# if ! @HAVE_TZSET@
_GL_FUNCDECL_SYS (tzset, void, (void));
# endif
_GL_CXXALIAS_SYS (tzset, void, (void));
# endif
_GL_CXXALIASWARN (tzset);
# endif
#endif
So, as I already saw in the readme, we should be building with clib2!
Okay, so now I try (after cleaning out directory completely. Essentially, deleting it and copying a new one):
./configure --host=ppc-amigaos CFLAGS=-mcrt=clib2
in this case, we get a Makefile again, but:
make
results in:
make[2]: Entering directory '/home/Amiga/coreutils-master'
CC lib/copy-acl.o
In file included from lib/acl.h:23,
from lib/copy-acl.c:22:
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include/stdbool.h:58:2: warning: #warning C99 header file used by non-C99 compliant compiler.
CC lib/set-acl.o
In file included from lib/acl.h:23,
from lib/set-acl.c:22:
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include/stdbool.h:58:2: warning: #warning C99 header file used by non-C99 compliant compiler.
CC lib/acl-errno-valid.o
In file included from ./lib/acl.h:23,
from lib/acl-errno-valid.c:22:
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include/stdbool.h:58:2: warning: #warning C99 header file used by non-C99 compliant compiler.
CC lib/acl-internal.o
In file included from lib/acl.h:23,
from lib/acl-internal.c:22:
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include/stdbool.h:58:2: warning: #warning C99 header file used by non-C99 compliant compiler.
In file included from ./lib/stdlib.h:96,
from lib/acl-internal.h:23,
from lib/acl-internal.c:24:
./lib/unistd.h:1108: error: conflicting types for 'gethostname'
/opt/ppc-amigaos/ppc-amigaos/SDK/clib2/include/unistd.h:157: error: previous declaration of 'gethostname' was here
So, function 'gethostname' was already:
extern int gethostname(const char *name, size_t namelen);
But in the core-utils directory that I am trying to build:
_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
_GL_ARG_NONNULL ((1)));
already exists.
Quote:
PRESUMPTION: Sure, I can hack to get passed this, but clearly I am not doing something correct in the initial configuration.
===Help===So, I am just wondering if someone can help point me in the right direction.
Thanks all.