Coder Social home page Coder Social logo

Comments (37)

johnsonjh avatar johnsonjh commented on July 22, 2024 3

Hi, just wanted to say, although the ppc branch is a bit old and a bit of a mess, I was able to use it to build a current cross-compiler for PPC and PPC64 using GCC 12.2.0, which I completely failed to do on my own for an entire day. I did end up just disabling C++ because it was giving me a problem and I don't need it, so perhaps someone might be willing to revive it if they do need it.

Your posts above (#50 (comment)) was really useful. I had duplicated a lot of work and was stumped with the ld: in section __TEXT,__text reloc 1: sectionForNum(4) section number not for any section file '...../crt1.o message, trying to use the 10.4 SDK, and searching for that found this issue. Good thing it was pretty unique.

I also have to admit, I looked at this repo while first attempting this, but I moved on quickly because I didn't see any PPC support, and didn't investigate further to find out it was in a branch!

I am getting a osxcross: warning: cannot find apple gcc intrinsic headers; please report this issue to the OSXCross project message, and only for ppc64, but I can easily work around it, and haven't investigated it yet.

Thanks so much!

from osxcross.

jlsantiago0 avatar jlsantiago0 commented on July 22, 2024 1

I have submitted a PR #390 to the ppc-test branch that I used to get OS X Cross + SDK-10.5 + mainline GCC-5.5.0 to target PowerPC and PowerPC64 .

I also provided detailed documentation on how I got it all built and scripts to test building some non-trivial projects Like OpenSSL, WGet, CURL and some C++11 and C++14 programs using the toolchain.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

I can't really get any further either.

This is what I have so far:

Build OSXCross the usual way

SDK_VERSION=10.4 ./build.sh
eval $(osxcross-conf)

Make the SDK GCC "compatible"

cd $OSXCROSS_SDK

cd /Library
ln -sf ../System/Library/Frameworks .
cd ../usr/lib
ln -s libstdc++.6.dylib libstdc++.dylib

Create PowerPC symlinks

cd $OSXCROSS_TARGET_DIR/bin

for arch in powerpc powerpc64; do \
  for tool in $(find . -name "x86_64-*"); do \
   ln -sf $tool $(echo $tool | sed "s/x86_64-/$arch-/"); \
  done \
done

rm powerpc*-*clang*

Build GCC

cd ~/tmp

wget https://opensource.apple.com/tarballs/gcc_42/gcc_42-5577.tar.gz
tar xf gcc-42-5577.tar.gz

cd gcc-42-5577

mkdir build
cd build

CC="clang -std=gnu89 -w" \
../configure \
 --target=powerpc-apple-$OSXCROSS_TARGET \
 --prefix=$OSXCROSS_TARGET_DIR \
 --with-sysroot=$OSXCROSS_SDK \
 --with-ld=$(which powerpc-apple-$OSXCROSS_TARGET-ld) \
 --with-as=$(which powerpc-apple-$OSXCROSS_TARGET-as) \
 --enable-languages=c,c++,objc,obj-c++ \
 --enable-wchar_t=no \
 --with-gxx-include-dir=/usr/include/c++/4.0.0

make

... fails with:

/home/thomas/tmp/gcc_42-5577/build/./gcc/xgcc -B/home/thomas/tmp/gcc_42-5577/build/./gcc/ -B/data/development/osxcross-ng/target/bin/../powerpc-apple-darwin8/bin/ -B/data/development/osxcross-ng/target/bin/../powerpc-apple-darwin8/lib/ -isystem /data/development/osxcross-ng/target/bin/../powerpc-apple-darwin8/include -isystem /data/development/osxcross-ng/target/bin/../powerpc-apple-darwin8/sys-include -O2 -g -O2  -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include  -I../../gcc/../libdecnumber -I../libdecnumber  -mlongcall \
  -c ../../gcc/config/darwin-crt2.c -o crt2.o
/tmp/cczpsINq.s:40:Unknown relocation type
/tmp/cczpsINq.s:42:Unknown relocation type
/tmp/cczpsINq.s:46:Unknown relocation type
/tmp/cczpsINq.s:47:Unknown relocation type
/tmp/cczpsINq.s:49:Unknown relocation type
/tmp/cczpsINq.s:56:Unknown relocation type
/tmp/cczpsINq.s:58:Unknown relocation type
/tmp/cczpsINq.s:61:Unknown relocation type
/tmp/cczpsINq.s:62:Unknown relocation type
/tmp/cczpsINq.s:75:Unknown relocation type
/tmp/cczpsINq.s:76:Unknown relocation type
/tmp/cczpsINq.s:77:Unknown relocation type
/tmp/cczpsINq.s:78:Unknown relocation type

I also tried to build gcc-42-5577 on Mac OS X, but unfortunately, Xcode doesn't come with a PowerPC assembler anymore.

Maybe I can make clang target PowerPC.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Just to let you know, I was able to get gcc 5.2.0 (ppc / ppc64) and clang (ppc) working.
I will setup a test branch within the next few days.

from osxcross.

snigel avatar snigel commented on July 22, 2024

That's awesome!

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

It was a lot of work to get PowerPC working, but here we go!

git clone https://github.com/tpoechtrager/osxcross.git
git checkout ppc-test

SDK_VERSION=10.5 ./build.sh # build.sh will detect PowerPC support automatically

# If you end up with powerpc-* symlinks in target/bin, then everything went well.

POWERPC=1 ./build_gcc.sh # build ppc64/ppc gcc
./build_gcc.sh           # build x86_64/i386 gcc

I came across a lot of issues while adding ppc support, including:

  • Recent ld64 versions do not support ppc/ppc64 anymore.

    After some googling, I found a way to add back ppc/ppc64 support via
    https://github.com/michaelweiser/ld64.

    I created a ppc branch @ cctools-port for it.

  • PPC assembler brokenness.

    Fixed via https://svn.macports.org/repository/macports/trunk/dports/devel/cctools/files/PR-37520.patch.

  • Clang <= 3.5 passes '-arch powerpc' instead of '-arch ppc' to the linker.

    Fixed by adding powerpc* aliases to ld64/as.

  • Clang <= 3.4 attempts to use powerc-apple-darwinX-gcc as assembler when targeting PowerPC

    Fix: Do not use clang <= 3.4 when targeting PowerPC.

  • LD64 > 97.17 doesn't like the 10.4 SDK's crt1.o.

    Fix 1: Do not use the 10.4 SDK when you want to target ppc.
    Fix 2: Rebuild the crt blobs, the sources can be found here.

    ld: in section __TEXT,__text reloc 1: sectionForNum(4) section number not for any section file '...../crt1.o
    ... is what you'd get otherwise, not a porting bug: https://stackoverflow.com/questions/5409860/unable-to-link-ppc-after-upgrading-to-xcode-4.

    If you want to target 10.4, use the 10.5 SDK + export MACOSX_DEPLOYMENT_TARGET=10.4 instead.

  • Clang + ppc64 only works for very simple sources.

    $ ./target/bin/powerpc64-apple-darwin9-clang++ ~/tmp/test.cpp
    fatal error: error in backend: Relocation emission for MachO/PPC64 unimplemented.
    clang-3.7: error: clang frontend command failed with exit code 70 (use -v to see invocation)

    Fix: Do not use clang when targeting ppc64.

So, in conclusion... avoid the 10.4 SDK and do not use clang when targeting ppc64.


Please let me know if everything works as expected, thanks!
I can't test whether the produced binaries work or not.

from osxcross.

snigel avatar snigel commented on July 22, 2024

This is great, I will test to build binaries. Thanks for your effort.

from osxcross.

snigel avatar snigel commented on July 22, 2024

I had trouble producing a working binary for gcc.

git clone https://github.com/tpoechtrager/osxcross.git
cd osxcross
git checkout ppc-test
git pull
SDK_VERSION=10.5 ./build.sh
cp MacOSX10.5.pkg tarballs/
GCC_VERSION=5.2.0 ENABLE_FORTRAN=1 POWERPC=1 ./build_gcc.sh
snigel@ubuntu:~/osxcross$ oppc32-gcc
Undefined symbols for architecture ppc:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found for architecture ppc
collect2: error: ld returned 1 exit status

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Not much of an issue, have you actually tried to compile something? ;-)

Surviving build_gcc.sh usually already means a working gcc (the cross compiler is already used to compile libgcc, libstdc++, etc.).

Simply ignore the output of gcc <no src files>. Nothing to worry about.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

I fixed the Undefined symbols for architecture ppc: "_main", referenced from: "issue",
you now get the expected output.

$ ./target/bin/oppc64-gcc
powerpc64-apple-darwin9-gcc: fatal error: no input files
compilation terminated.

$ ./target/bin/powerpc-apple-darwin9-gcc
powerpc-apple-darwin9-gcc: fatal error: no input files
compilation terminated.

from osxcross.

snigel avatar snigel commented on July 22, 2024

Not much of an issue, have you actually tried to compile something? ;-)

Yes, I tried to build rtorrent, but the error I got was actually not related to the compiler.
But the first thing I saw was the compiler output, ran the compiler separately and thought it was broken.

Anyhow, I'm trying to find something that I can compile and test run. Tried wget, rtorrent and curl, they fail for different reasons during the configuration phase.

So for now I just tried two simple hello world in C and in C++
iBookG4:~ snigel$ ./c.out
Hello World

iBookG4:~ snigel$ ./cpp.out
Hello, world!

I've been thinking about trying out macports, but your documentation says that macports does not support 10.5. I am running macports 2.3.4 (latest version) on my 10.5 machine though.

It also looks like there is 10.5 content in that release
http://sourceforge.net/projects/macports/files/MacPorts/2.3.4/

Tried to launch it anyway,
snigel@ubuntu:/src$ export MACOSX_DEPLOYMENT_TARGET=10.5
snigel@ubuntu:
/src$ osxcross-macports
unsupported deployment target

Sure, I can hardcode to change it, but perhaps you have more insight on why it's unsupported?

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Yes, I tried to build rtorrent, but the error I got was actually not related to the compiler.
But the first thing I saw was the compiler output, ran the compiler separately and thought it was broken.

Anyhow, I'm trying to find something that I can compile and test run. Tried wget, rtorrent and curl, they fail for different reasons during the configuration phase.

I was able to build wget and curl.

Edit: Added missing if [ $ARCH == powerpc ].

mkdir -p $HOME/tmp/ppc-test
cd $HOME/tmp/ppc-test

# Get and extract openssl-1.0.2d, wget-1.16 and curl-7.45.0

ARCH=powerpc64
COMPILER=gcc

## OpenSSL ##

cd openssl-1.0.2d
EXTRACONFFLAGS=""
[ $COMPILER == clang ] && EXTRACONFFLAGS="no-asm"
if [ $ARCH == powerpc ]; then
  TARGET=darwin-ppc-cc
else
  TARGET=darwin64-ppc-cc
fi
./Configure $TARGET \
  --prefix=$HOME/tmp/ppc-test/$ARCH-$COMPILER $EXTRACONFFLAGS
make clean 2>/dev/null || true
# don't use -j
make install \
  CC="$ARCH-apple-darwin9-$COMPILER" \
  AR="$ARCH-apple-darwin9-ar r" \
  RANLIB="$ARCH-apple-darwin9-ranlib"
cd ..

## wget ##

cd wget-1.16
make clean 2>/dev/null || true
CC=$ARCH-apple-darwin9-$COMPILER ./configure \
  --host=$ARCH-apple-darwin9 --prefix=$HOME/tmp/ppc-test/$ARCH-$COMPILER \
  --with-ssl=openssl --with-libssl-prefix=$HOME/tmp/ppc-test/$ARCH-$COMPILER
make install -j $(nproc)
cd ..

## curl ##

cd curl-7.45.0
CC=$ARCH-apple-darwin9-$COMPILER ./configure \
  --host=powerpc-apple-darwin9 --with-ssl=$HOME/tmp/ppc-test/$ARCH-$COMPILER \
  --prefix=$HOME/tmp/ppc-test/$ARCH-$COMPILER
make install -j $(nproc)
cd ..

# Do this for gcc (powerpc/powerpc64) and clang (powerpc)

I've been thinking about trying out macports, but your documentation says that macports does not support 10.5. I am running macports 2.3.4 (latest version) on my 10.5 machine though.

There are no pre-built packages for 10.5 (anymore?).

https://packages.macports.org/<pkg>

from osxcross.

snigel avatar snigel commented on July 22, 2024

Oh, I never use prebuilt packages with macports anyway. That's why I thought I made a great case for osxcross. Get all required sources, build them on a fast machine and transfer the binaries to my slower ppc machine.

I will try the above script for test compiles, allthough, I can only test for ppc32.

from osxcross.

snigel avatar snigel commented on July 22, 2024

I went to /home/tmp/ppc-test and then

wget https://www.openssl.org/source/openssl-1.0.2d.tar.gz
wget http://ftp.gnu.org/gnu/wget/wget-1.16.tar.gz
wget http://curl.haxx.se/download/curl-7.45.0.tar.gz
tar zxf curl-7.45.0.tar.gz
tar zxf wget-1.16.tar.gz
tar zxf openssl-1.0.2d.tar.gz
tar: A lone zero block at 52140

I tried redownloading openssl several times from the official homepage with the same result.

This built fine, so let's change arch to something I can test:
ARCH=powerpc

This also built fine, but I saw something scroll by that didn't look right:

/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: ▒▒▒▒: not found
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: Syntax error: Unterminated quoted string
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: ▒▒▒▒: not found
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: Syntax error: Unterminated quoted string
WARNING: Skipping duplicate certificate dsa-pca.pem
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: ▒▒▒▒: not found
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: Syntax error: Unterminated quoted string
WARNING: Skipping duplicate certificate dsa-ca.pem
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: ▒▒▒▒: not found
/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: Syntax error: Unterminated quoted string
WARNING: Skipping duplicate certificate ca-cert.pem
final section layout:

During the build I could also see my terminal doing a visual bell, so I guess something is being outputted that shouldn't be.

Also, this is weird, why aren't all the binaries in my 32bit build?

powerpc-gcc/bin$ ls -1
curl
curl-config
powerpc64-gcc/bin$ ls -1
c_rehash
curl
curl-config
openssl
wget

Regardless I copied the powerpc-gcc directory to the ppc machine.

iBookG4:~ snigel$ ./powerpc-gcc/bin/curl
dyld: Library not loaded: /home/snigel/tmp/ppc-test/powerpc-gcc/lib/libcurl.4.dylib
  Referenced from: /Users/snigel/./powerpc-gcc/bin/curl
  Reason: Incompatible library version: curl requires version 9.0.0 or later, but libcurl.4.dylib provides version 5.0.0
Trace/BPT trap

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Also, this is weird, why aren't all the binaries in my 32bit build?

Looks like OpenSSL and wget failed to build. Use set -ex to see what's causing the build failure.

/home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: 1: /home/snigel/tmp/ppc-test/openssl-1.0.2d/util/../apps/openssl: ▒▒▒▒: not found

What's triggering that output? make install?

Reason: Incompatible library version: curl requires version 9.0.0 or later, but libcurl.4.dylib provides version 5.0.0

Either link statically or adjust DYLD_LIBRARY_PATH.

DYLD_LIBRARY_PATH=../lib ./curl

from osxcross.

snigel avatar snigel commented on July 22, 2024

Either link statically or adjust DYLD_LIBRARY_PATH.
Embarrassing, I misinterpreted that error message. When I pointed out DYLD_LIBRARY_PATH curl started instantly. Thanks for your patience.

I tried rerunning the script with set -ex

make[2]: Entering directory '/home/snigel/tmp/ppc-test/openssl-1.0.2d/test'
( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first -L.. -lssl -L.. -lcrypto  }"; LDCMD="${LDCMD:-powerpc-apple-darwin9-gcc}"; LDFLAGS="${LDFLAGS:--DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch ppc -O3 -DB_ENDIAN -Wa,-force_cpusubtype_ALL -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DVPAES_ASM}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=constant_time_test} constant_time_test.o ${LIBDEPS} )
final section layout:
    __TEXT/__text addr=0x00001F8C, size=0x00000190, fileOffset=0x00000F8C, type=1
    __TEXT/__text_startup addr=0x0000211C, size=0x00000990, fileOffset=0x0000111C, type=1
    __TEXT/__symbol_stub1 addr=0x00002AAC, size=0x00000030, fileOffset=0x00001AAC, type=28
    __TEXT/__cstring addr=0x00002ADC, size=0x000004C8, fileOffset=0x00001ADC, type=13
    __TEXT/__const addr=0x00002FA4, size=0x0000005C, fileOffset=0x00001FA4, type=0
    __DATA/__dyld addr=0x00003000, size=0x0000001C, fileOffset=0x00002000, type=30
    __DATA/__nl_symbol_ptr addr=0x0000301C, size=0x00000008, fileOffset=0x0000201C, type=29
    __DATA/__la_symbol_ptr addr=0x00003024, size=0x0000000C, fileOffset=0x00002024, type=27
    __DATA/__const addr=0x00003030, size=0x00000004, fileOffset=0x00002030, type=0
    __DATA/__data addr=0x00003034, size=0x00000014, fileOffset=0x00002034, type=0
ld: 32-bit absolute address out of range (0x100002FD4 max is 4GB): from anon + 0x00000000 (0x00003030) to 0x100002FD4 in 'anon' from constant_time_test.o for architecture ppc
collect2: error: ld returned 1 exit status
../Makefile.shared:164: recipe for target 'link_app.' failed
make[2]: *** [link_app.] Error 1
make[2]: Leaving directory '/home/snigel/tmp/ppc-test/openssl-1.0.2d/test'
Makefile:525: recipe for target 'constant_time_test' failed
make[1]: *** [constant_time_test] Error 2
make[1]: Leaving directory '/home/snigel/tmp/ppc-test/openssl-1.0.2d/test'
Makefile:291: recipe for target 'build_tests' failed
make: *** [build_tests] Error 1

The error itself looks quite straight forward, we're out of memory range. But why, I don't think it's curl. So maybe something is still producing 64bit code somewhere.

If I comment out "make install" for openssl, the script stops at wget instead:

mv -f .deps/ftp-opie.Tpo .deps/ftp-opie.Po
powerpc-apple-darwin9-gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/home/snigel/tmp/ppc-test/powerpc-gcc/etc/wgetrc\" -DLOCALEDIR=\"/home/snigel/tmp/ppc-test/powerpc-gcc/share/locale\" -I.  -I../lib -I../lib   -g -O2 -MT openssl.o -MD -MP -MF .deps/openssl.Tpo -c -o openssl.o openssl.c
openssl.c: In function 'ssl_init':
openssl.c:195:3: warning: implicit declaration of function 'ENGINE_load_builtin_engines' [-Wimplicit-function-declaration]
   ENGINE_load_builtin_engines();
   ^
openssl.c:197:7: error: 'CONF_MFLAGS_DEFAULT_SECTION' undeclared (first use in this function)
       CONF_MFLAGS_DEFAULT_SECTION|CONF_MFLAGS_IGNORE_MISSING_FILE);
       ^
openssl.c:197:7: note: each undeclared identifier is reported only once for each function it appears in
openssl.c: In function 'ssl_check_certificate':
openssl.c:681:49: warning: implicit declaration of function 'a2i_IPADDRESS' [-Wimplicit-function-declaration]
       ASN1_OCTET_STRING *host_in_octet_string = a2i_IPADDRESS (host);
                                                 ^
openssl.c:681:49: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
Makefile:1512: recipe for target 'openssl.o' failed
make[2]: *** [openssl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/utils.Tpo .deps/utils.Po
make[2]: Leaving directory '/home/snigel/tmp/ppc-test/wget-1.16/src'
Makefile:1342: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/home/snigel/tmp/ppc-test/wget-1.16'
Makefile:1632: recipe for target 'install' failed
make: *** [install] Error 2

So indeed it looks like both wget and curl are failing on make install.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Need the whole output to see what's going on.

./Configure darwin-ppc-cc --prefix=$HOME/tmp/ppc-test/powerpcc-gcc
make clean
make install CC="powerpc-apple-darwin9-gcc" AR="powerpc-apple-darwin9-ar r" RANLIB="powerpc-apple-darwin9-ranlib" &>build.log

Edit: Never mind... I am getting the same error too with gcc; clang seems to work.

I will try to add "Apple GCC" support once I am done with porting the new cctools/ld64.


Edit 2: "Apple GCC" seems to work too.

However, it will take a while until I will have a build script ready.

from osxcross.

snigel avatar snigel commented on July 22, 2024

Is this as it should be? Both powerpc-apple-darwin9-gcc and powerpc64-apple-darwin9-gcc points to the same wrapper, with 64 in its name.

readlink $(which powerpc-apple-darwin9-gcc)
powerpc64-apple-darwin9-wrapper
readlink $(which powerpc64-apple-darwin9-gcc)
powerpc64-apple-darwin9-wrapper

On the other hand, I see no "powerpc-apple-darwin9-wrapper" existing in my file tree.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Yes. My wrapper passes some flags "under the hood" to the compiler.
You can see them by setting OCDEBUG to 1.

$ OCDEBUG=1 oppc32-gcc ~/tmp/test.c

There's something wrong with gcc, not with the wrapper.
I was able to compile OpenSSL with the Apple GCC and with clang.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

You can now build an Apple GCC via:

Edit: It's APPLE_GCC=1 not APPLEGCC=1

POWERPC=1 APPLE_GCC=1 ./build_gcc.sh

I successfully built LLVM/Clang 3.4, OpenSSL, wget and curl with it.

Please do the same and let me know whether the resulting binaries work.

LLVM/Clang 3.4 configure flags:

CC=powerpc-apple-darwin9-gcc CXX=powerpc-apple-darwin9-g++ \
  ../../llvm/configure --host=powerpc-apple-darwin9 --disable-assertions --enable-optimized

Or try my binaries: http://51.254.123.149/thomas/llvm-clang-3.4-ppc32.tar.xz
(sha256: 61791e0c09cb3fd271991f1d10b8f23a12c94d84a5b2377f596e890b82457f80)

from osxcross.

snigel avatar snigel commented on July 22, 2024

Hi, I downloaded your binaries to my ppc machine.
I could not see curl, wget or curl though?

Anyhow, I can launch some of the applications inside.
cd Release/bin
./clang
clang: error: no input files
./count
usage: ./count
./FileCheck
FileCheck: Not enough positional command line arguments specified!
Must specify at least 1 positional arguments: See: ./FileCheck -help

Should I test something specific?

from osxcross.

WinterMute avatar WinterMute commented on July 22, 2024

I don't know if you can be bothered with supporting 10.4 for ppc but your issue may be that the 10.4u SDK needs apple gcc 4.0. My Snow Leopard machine has 4.0.1 build 5494.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

@snigel:

No, that's enough. Thanks!

I left curl, wget and OpenSSL out because they are easy enough to build.

I will finish PowerPC support at a later time point, most things should work already though.

@WinterMute:

I think the problem is caused by ld64, not by the compiler.
LD64 > 97 seems to cause troubles. What linker version are you using on that machine?

from osxcross.

WinterMute avatar WinterMute commented on July 22, 2024

@tpoechtrager

I have this
@(#)PROGRAM:ld PROJECT:ld64-97.17
llvm version 2.9svn, from Apple Clang 1.7 (build 77)

But trying to build anything against 10.4u SDK with gcc 4.2 fails quite badly on this machine.

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

@tpoechtrager
I tried to build the PowerPC GCC under cygwin, but I got this error:

make[2]: *** No rule to make target 'host-cygwin.o', needed by 'libbackend.a'. Stop.

Apparently host-cygwin.c and co are missing from this version of GCC.

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

@BSzili: Is https://github.com/gcc-mirror/gcc/blob/gcc-4_2-branch/gcc/config/i386/host-cygwin.c of any help? Copy the file(s) into build/gcc/[...] then cd into build/gcc/build_* and re-run make.

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

Thanks for the tip! Copying just that one file wasn't enough, but copying the rest of the cygwin-related ones solved the problem:

cygwin.asm
cygwin.h
cygwin1.c
cygwin2.c
host-cygwin.c
t-cygwin
x-cygwin
xm-cygwin.h

Now I'm stuck again at a different place, because it can't link libgcc:
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_trampoline.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_ctors.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_powixf2.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_mulxc3.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_divxc3.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixunsxfsi.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixxfdi.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixunsxfdi.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_floatdixf.o) has no symbols powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_floatundixf.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_trampoline.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_ctors.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_powixf2.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_mulxc3.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_divxc3.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_fixunsxfsi.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_fixxfdi.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_fixunsxfdi.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_floatdixf.o) has no symbols /home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file: static/libgcc.a(_floatundixf.o) has no symbols powerpc64-apple-darwin8-ranlib -c static/libgcc.a ld: unknown/unsupported architecture name for: -arch ppc64 collect2: ld returned 1 exit status libgcc.mk:731: recipe for target 'libgcc_s.dylib' failed make[3]: *** [libgcc_s.dylib] Error 1
I copied more similar errors into a pastebin:
http://pastebin.com/YabckMBB

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

rm -rf target and re-run build.sh. I think you built the linker from
the wrong branch.

On Thu, Jan 28, 2016 at 12:25 PM, Szilárd Biró [email protected]
wrote:

Thanks for the tip! Copying just that one file wasn't enough, but copying
the rest of the cygwin-related ones solved the problem:

cygwin.asm
cygwin.h
cygwin1.c
cygwin2.c
host-cygwin.c
t-cygwin
x-cygwin
xm-cygwin.h

Now I'm stuck again at a different place, because it can't link libgcc:
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_trampoline.o) has no
symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_ctors.o) has no symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_powixf2.o) has no symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_mulxc3.o) has no symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_divxc3.o) has no symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixunsxfsi.o) has no
symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixxfdi.o) has no symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_fixunsxfdi.o) has no
symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_floatdixf.o) has no
symbols
powerpc64-apple-darwin8-ranlib: file: ./libgcc.a(_floatundixf.o) has no
symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_trampoline.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_ctors.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_powixf2.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_mulxc3.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_divxc3.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_fixunsxfsi.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_fixxfdi.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_fixunsxfdi.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_floatdixf.o) has no symbols
/home/BSzili/osxcross/target/bin/x86_64-apple-darwin8-ranlib: file:
static/libgcc.a(_floatundixf.o) has no symbols
powerpc64-apple-darwin8-ranlib -c static/libgcc.a
ld: unknown/unsupported architecture name for: -arch ppc64
collect2: ld returned 1 exit status
libgcc.mk:731: recipe for target 'libgcc_s.dylib' failed
make[3]: *** [libgcc_s.dylib] Error 1

I copied more similar errors into a pastebin:
http://pastebin.com/YabckMBB


Reply to this email directly or view it on GitHub
#50 (comment)
.

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

I did a full rebuild, but something is still not right about the linker, because it does'nt seem to produce working executables:

...
checking for pid_t... yes
checking for library containing strerror... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:9432: recipe for target 'configure-target-libiberty' failed
make[1]: *** [configure-target-libiberty] Error 1
make[1]: Leaving directory '/home/BSzili/osxcross/build/gcc-5575.11/build_powerpc'
Makefile:652: recipe for target 'all' failed
make: *** [all] Error 2

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Did you set MACOSX_DEPLOYMENT_TARGET? If so, unset that variable.

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

No, I definitely didn't set MACOSX_DEPLOYMENT_TARGET. I ran these commands:

./build.sh
POWERPC=1 APPLE_GCC=1 ./build_gcc.sh

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Please post config.log.

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

Here it is:
http://pastebin.com/SMfX2inf

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

Hmm... what's the output of:

/home/BSzili/osxcross/build/gcc-5575.11/build_powerpc/./gcc/xgcc -B/home/BSzili/osxcross/build/gcc-5575.11/build_powerpc/./gcc/ -B/home/BSzili/osxcross/target/bin/../powerpc-apple-darwin8/bin/ -B/home/BSzili/osxcross/target/bin/../powerpc-apple-darwin8/lib/ -isystem /home/BSzili/osxcross/target/bin/../powerpc-apple-darwin8/include -isystem /home/BSzili/osxcross/target/bin/../powerpc-apple-darwin8/sys-include -c -O2 -g -O2     <testfile.c>

?

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

I only get an error:

-bash: syntax error near unexpected token `newline'

Removing the angled brackets, it get an error about testfile.c not existing. Isn't this file supposed to be generated by the configure script during the tests?

from osxcross.

tpoechtrager avatar tpoechtrager commented on July 22, 2024

echo "int main(void){return 0;}" > testfile.c

Would it be much of a hassle to set up a Linux VM for OSXCross? Cygwin is freaking slow and thus very annoying to debug.

All I get when I am trying to build the Apple GCC is:

Makefile:652: recipe for target 'all' failed
make: *** [all] Error 2
make: INTERNAL: Exiting with 7 jobserver tokens available; should be 8!

from osxcross.

BSzili avatar BSzili commented on July 22, 2024

I could, but that would kind of defeat the purpose of being able to compile all of my executables from the same environment. I tried compiling that simple test file, and I got and object without a hitch. I'll try to look more into why the libiberty configure script fails.

from osxcross.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.