Trivial patch to allow bootstrap on MacOS

Message ID 50B82F76-1421-4480-B730-11ED5CDFCFE8@hs-esslingen.de
State New
Headers show
Series
  • Trivial patch to allow bootstrap on MacOS
Related show

Commit Message

Keller, Rainer Nov. 28, 2019, 8:05 a.m.
Dear all,
the following is required to allow bootstrap in libcc1 during stage3 on MacOS Catalina (10.15). libcc1 invokes g++ with —nostdinc++

MacOS Catalina doesn’t provide /usr/include anymore, instead one builds with:
OSX_SDK_VERSION=`xcodebuild -showsdks | grep 'macOS\ 10' | cut -f2- -d'-' | cut -f2 -d' '`
OSX_SDK_PATH=`xcodebuild -sdk $OSX_SDK_VERSION -version | grep -E '^Path: ' | cut -f2 -d' '`

configure … --with-build-sysroot=$OSX_SDK_PATH

GMP however is installed elsewhere (by Homebrew, MacPorts etc), so ignore any -nostdinc

Please note, I am not subscribed to the list.

Best regards,
Rainer Keller

gcc/Changelog:
	* Have gmp.h be found outside of sysroot

--

Comments

Iain Sandoe Nov. 28, 2019, 8:30 a.m. | #1
Hello Rainer,

thanks for the patch, but I think it’s only a work-around to part of the  
problem and there are alternate strategies for the “usual case” on  
MacOS/Darwin.

Keller, Rainer <Rainer.Keller@hs-esslingen.de> wrote:

> the following is required to allow bootstrap in libcc1 during stage3 on  

> MacOS Catalina (10.15). libcc1 invokes g++ with —nostdinc++

>

> MacOS Catalina doesn’t provide /usr/include anymore, instead one builds  

> with:

> OSX_SDK_VERSION=`xcodebuild -showsdks | grep 'macOS\ 10' | cut -f2- -d'-'  

> | cut -f2 -d' '`

> OSX_SDK_PATH=`xcodebuild -sdk $OSX_SDK_VERSION -version | grep -E '^Path:  

> ' | cut -f2 -d' '`

>

> configure … --with-build-sysroot=$OSX_SDK_PATH


—with-build-sysroot=  is known to have some problems;

see, for example, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885

There is also a current series of patches on the topic from Maciej Rozicki.

I’m not sure what the intent is in using it in the MacOS builds - since I  
expect you will be using the same sysroot (SDK) at run time as you are at  
build time?

====

—with-sysroot= does, however, work (we also now honour SDKROOT in trunk,  
open branches and gcc-7, but not on gcc-6 or gcc-5 [I will probably do some  
Darwin-specific extra patches for the closed branches at some point])

I have sucessfully bootstrapped and tested on Catalina see (for example):

https://gcc.gnu.org/ml/gcc-testresults/2019-11/msg01492.html

Usually, I am using the command line tools, so the installation is not  
going to move….

… however, if you configure with “—with-sysroot=$OSX_SDK_PATH” and then the  
path moves (e.g. you relocate XCode) then you would have to supply the SDK  
position at runtime anyway (either by setting SDKROOT or by passing  
—sysroot=$NEW_SDK_POSITION for each compilation line)

> GMP however is installed elsewhere (by Homebrew, MacPorts etc), so ignore  

> any -nostdinc


it also works to symlink the sources for gmp, mpfr, mpc (and isl, if you  
use it) into the source tree - those then get boostrapped along with the  
compiler and there are no resulting external dependencies (which I find  
preferable).

However, —with-gmp= etc should also work with it (I’ll take a look at that  
case).

> Please note, I am not subscribed to the list.


HTH,
Iain

>

> Best regards,

> Rainer Keller

>

> gcc/Changelog:

> 	* Have gmp.h be found outside of sysroot

>

> --

> Index: gcc/system.h

> ===================================================================

> --- gcc/system.h        (revision 278783)

> +++ gcc/system.h        (working copy)

> @@ -684,7 +684,7 @@

>

> /* Do not introduce a gmp.h dependency on the build system.  */

> #ifndef GENERATOR_FILE

> -#include <gmp.h>

> +#include "gmp.h"

> #endif

>

> /* Get libiberty declarations.  */
Iain Sandoe Nov. 28, 2019, 3:34 p.m. | #2
Hello again Rainer,

Iain Sandoe <idsandoe@googlemail.com> wrote:

>> GMP however is installed elsewhere (by Homebrew, MacPorts etc), so  

>> ignore any -nostdinc

>

> it also works to symlink the sources for gmp, mpfr, mpc (and isl, if you  

> use it) into the source tree - those then get boostrapped along with the  

> compiler and there are no resulting external dependencies (which I find  

> preferable).

>

> However, —with-gmp= etc should also work with it (I’ll take a look at  

> that case).


It works fine when using —with-sysroot=   and  
—with-gmp=/somewhere/outside/the/SDK  (/opt/….)

So, I think one can get the desired behaviour with this configuration scheme.

thanks
Iain
Keller, Rainer Nov. 28, 2019, 10:11 p.m. | #3
Dear Iain,
thanks for the quick reply. I wasn’t aware of the ticket 79885.

Yes, the intent is to use the same sysroot for build & run.

Hmm, the —with-sysroot is from gcc/configure option — not from the main configure.
Not wanting to turn this into a bug-report, but… using —with-sysroot instead of —with-build-sysroot failed, too.

Let’s keep track of this in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92719
I am happy to provide more info.

Thanks again for Your help,
Rainer


> On 28. Nov 2019, at 16:34, Iain Sandoe <idsandoe@googlemail.com> wrote:

> 

> Hello again Rainer,

> 

> Iain Sandoe <idsandoe@googlemail.com> wrote:

> 

>>> GMP however is installed elsewhere (by Homebrew, MacPorts etc), so ignore any -nostdinc

>> 

>> it also works to symlink the sources for gmp, mpfr, mpc (and isl, if you use it) into the source tree - those then get boostrapped along with the compiler and there are no resulting external dependencies (which I find preferable).

>> 

>> However, —with-gmp= etc should also work with it (I’ll take a look at that case).

> 

> It works fine when using —with-sysroot=   and —with-gmp=/somewhere/outside/the/SDK  (/opt/….)

> 

> So, I think one can get the desired behaviour with this configuration scheme.

> 

> thanks

> Iain

> 


---------------------------------------------------------------------
Prof. Dr.-Ing. Rainer Keller, Hochschule Esslingen
Professor für Betriebssysteme, verteilte und parallele Systeme
Fakultät Informationstechnik
Flandernstr. 101, Raum F01.320
73732 Esslingen
T.: +49 (0)711 397-4165
F.: +49 (0)711 397-48 4165

Patch

Index: gcc/system.h
===================================================================
--- gcc/system.h        (revision 278783)
+++ gcc/system.h        (working copy)
@@ -684,7 +684,7 @@ 
 
 /* Do not introduce a gmp.h dependency on the build system.  */
 #ifndef GENERATOR_FILE
-#include <gmp.h>
+#include "gmp.h"
 #endif
 
 /* Get libiberty declarations.  */