config-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for config.guess for "cross-compiling" x86_64 -> powerpc on Mac OS


From: Mojca Miklavec
Subject: Patch for config.guess for "cross-compiling" x86_64 -> powerpc on Mac OS X <= 10.6
Date: Tue, 18 Apr 2017 17:18:34 +0200

Hello,

I would like to request a patch for config.guess to partially address
some problems experienced when setting
    CC="gcc -arch ppc"
on Mac OS X 10.4-10.6 i386 or x86_64.

My patch doesn't solve a similar fundamental problem that 'clang -arch
i386' would still be reported as x86_64 on OS X 10.7 and newer.

The patch is in attachment, the description of the problem follows below.

Applying the patch would let me build some piece of software (ppc
binaries on 64-bit 10.6) that I could build in any other way.



The problem is: when I compile with "gcc -arch i386" or "gcc -arch
ppc" on 10.6, here's what I get from config.guess:

- x86_64 => x86_64-apple-darwin10.8.0
- i386 => i386-apple-darwin10.8.0
- powerpc => i386-apple-darwin10.8.0

You can see there's a mixture of correct guesses (i386) and wrong ones
(i386 when it's in fact powerpc).

Currently:

- when compiling for i386 on >= 10.7, one always gets x86_64
  (the compiler is never consulted)

- when compiling for i386 or *ppc* on <= 10.6/intel, one always gets i386
   (the compiler is consulted whether "#ifdef __LP64__", but not
whether it is PPC)

- There are many other remaining potential problems and discrepancies
(the main one being inability to recognise 32-bit build on a 64-bit
OS), but I'm afraid to introduce a proper fix. The patch that I'm
sending is a compromise that only addresses one particular scenario
without compromising the inconvenience of calling the compiler on >=
10.7.


The main problem is that config.guess is being used by various
software packages to answer two completely different questions and the
answer might not always be the same:

(1) Which platform am I building for?
(2) Which platform am I running on / which binaries should I download?

I believe that there should be two tools to answer the above questions
separately.

I didn't test on a wide variety of platforms, but I suspect that when
someone provides CC="gcc -m32" on a 64-bit platform, then config.guess
will give the correct answer when building software. Some software
configurations use that to determine what assembler code to use for
compilation. Being able to answer that correctly requires running the
compiler.

The second question does not require running the compiler. When a Mac
OS X 10.6 user wants to determine whether he is on a 64-bit platform,
it's possible to simply check whether "sysctl -n hw.cpu64bit_capable"
returns anything.

For Mac OS X the config.guess script is using a weird mixture of both.
It asks the compiler to distinguish between 32-bit and 64-bit on Mac
OS X <= 10.6, but it doesn't use the compiler to distinguish between
32-bit and 64-bit on > 10.6 or to distinguish between ppc and intel
host when cross-compiling.

The annoying part is that simply running the compiler on a Mac without
having a compiler installed (not sure since which version that's the
case) fires up a GUI and asks you whether you want to install the
compiler (Xcode), so running the compiler comes with its own penalty.

Our project is using config.guess in exactly that way (just to figure
out the current platform) and asking users to install a few gigabytes
of compiler-related stuff just to figure out which binaries to
download is a bit of an overkill.

I know that this PPC stuff is totally obsolete, but building for
32-bit is still relevant in many cases (wine still has issues with
64-bit builds etc.).

Thank you very much,
    Mojca

Attachment: config.guess-ppc.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]