English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. C/C++ (https://eab.abime.net/forumdisplay.php?f=118)
-   -   Cross-Compiling and libs (https://eab.abime.net/showthread.php?t=106596)

alancfrancis 14 April 2021 00:38

Cross-Compiling and libs
 
Hi folks,

Another probably-basic question because I'm not very familiar with cross compiling under gcc (I've been using vbcc).

On a bit of a whim I thought I'd see whether I could get ruby building for the classic amiga. The source is downloadable and its a standard configure/make process on most unixy platforms (I'm on an intel Mac).

I have bebbos gcc toolchain installed and working very well for building stuff I wrote myself, no configure step necessary. It lives in /opt/amiga and the /opt/amiga/bin contains eg m68k-amigaos-gcc

I go into the ruby source dir and type

./configure --source m68k-amigaos and I get pretty far through...until.

Code:

configure: error: clock_gettime() or gettimeofday() must exist
Now a quick grep shows me that gettimeofday() exists in (amongst others) clib2 and libnix, so I know its "there", but I'm not familiar enough with configure to understand (a) how its actually deciding it can't find the function and (b) what arguments I need to pass to configure to tell it what it needs to know.

I know its a bit of a niche question, but I figure there's a lot of people here used to doing this kind of stuff :-).

Thanks in advance for any suggestions,

Alan

alancfrancis 14 April 2021 01:18

Just remembered this other post http://eab.abime.net/showthread.php?t=105897 which also had a problem with gettimeofday() :-/. So...

Code:

CFLAGS=-mcrt=clib2  ./configure --host m68k-amigaos
gets me further :-)

Code:

m68k-amigaos/bin/nm: sorry - this program has been built without plugin support
suggests I'm going to go have to play with configure/build on bebbo's toolchain. Its going to be a long night.

alancfrancis 14 April 2021 01:32

Final update of the evening is that I'm now stuck getting it to recognise /opt/amiga/m68k-amigaos/lib/libpthread.a

Code:

checking for pthread_create in -lthr... no
checking for pthread_create in -lpthread... no
checking for pthread_create in -lpthreads... no
checking for pthread_create in -lc... no
checking for pthread_create in -lc_r... no
checking for pthread_create in -lroot... no
configure: WARNING: "Don't know how to find pthread library on your system -- thread support disabled"

have tried messing with LDFLAGS to be super clear about -lpthread but no joy. I think its bedtime :-)

bebbo 14 April 2021 08:46

Quote:

Originally Posted by alancfrancis (Post 1476811)
Just remembered this other post http://eab.abime.net/showthread.php?t=105897 which also had a problem with gettimeofday() :-/. So...

Code:

CFLAGS=-mcrt=clib2  ./configure --host m68k-amigaos
gets me further :-)


I recommend using -libnix aka -mcrt=nix20 instead of clib2.



Quote:

Originally Posted by alancfrancis (Post 1476811)
Code:

m68k-amigaos/bin/nm: sorry - this program has been built without  plugin support
suggests I'm going to go have to play with configure/build on bebbo's toolchain. Its going to be a long night.



use the prefixed programs in $PREFIX/bin -> $PREFIX/bin/m68k-amigaos-nm

alancfrancis 14 April 2021 17:51

@bebbo

I tried -mcrt=nix20 and configure stopped dead at "checking your c compiler is working" :-/.

I hate that I can't find useful information to help me debug this stuff beyond a "it didn't work" error message. I feel like a 5 year old :-)

As regards a different nm I'm not sure how to point at those binaries beyond the --host m68k-amigaos that I am already using ?

alancfrancis 14 April 2021 18:15

I think the nm problem is just a bad error message, it has managed to auto-translate ranlib -> m68k-amigaos-ranlib for example. My thought is that it *is* using the correct binary but in the amiga-gcc/Makefile I see --disable-plugins

https://github.com/bebbo/amiga-gcc/b.../Makefile#L335

hence "this program has been built without plugin support"

alancfrancis 14 April 2021 20:52

So I changed that line in the amiga-gcc Makefile and rebuilt everything with --enable-plugins. On a whim I tried mcrt=nix20 so I could get the right error message to paste here, and I'll be damed but it worked right the way through.

Code:

CFLAGS=-mcrt=nix20 ./configure --host m68k-amigaos --enable-threads=posix
I have no explanation. I can look back in my history and see -mcrt=nix20 fail with

Code:

checking for m68k-amigaos-gcc-nm... m68k-amigaos-gcc-nm
checking for m68k-amigaos-m68k-amigaos-gcc-ranlib... no
checking for m68k-amigaos-gcc-ranlib... m68k-amigaos-gcc-ranlib
checking for m68k-amigaos-gcc... (cached) m68k-amigaos-gcc
checking whether the C compiler works... no
configure: error: in `/Users/acf/work/ruby-3.0.1':
configure: error: C compiler cannot create executables

Anyhoo. configure done. Now to try and build it :-)

alancfrancis 14 April 2021 21:05

Notes mostly for myself and anyone else who tries this later.

First thing I needed to do was define HAVE_GCC_ATOMIC_BUILTINS=1 to make include/ruby/atomic.h happy.

Have now hit an issue where coroutine/ucontext/Context.h is looking for <ucontext.h> which appears to be part of glibc but isn't present in opt/amiga. Investigations continue. :-)

https://github.com/lattera/glibc/blo...sys/ucontext.h

nyteshade 19 January 2023 17:35

Have you ever figured it out? Curious as I am looking around to see who has accomplished what with regards to Ruby on the Amiga. @alancfrancis


All times are GMT +2. The time now is 14:09.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04564 seconds with 11 queries