Bug 65294 - No easy way of setting default Mac OS X target - darwin_minversion not enough
Summary: No easy way of setting default Mac OS X target - darwin_minversion not enough
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.4
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-03 08:27 UTC by Peter Åstrand
Modified: 2017-12-21 10:05 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-apple-darwin10
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-07-19 00:00:00


Attachments
Activate parts of darwin_default_min_version() even when not cross (1.05 KB, patch)
2015-03-03 08:31 UTC, Peter Åstrand
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Åstrand 2015-03-03 08:27:54 UTC
Host: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Target: x86_64-apple-darwin10
Mac OS X SDK: 10.6

We want to configure GCC so that OS X 10.6 is the default target. For this, we changed DARWIN_MINVERSION_SPEC to be "10.6". This seemed to work - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is 1060. However, we later then realized that calling gcc with -mmacosx-version-min=10.6 gave a different behaviour. For example, in the latter case, ld is called with -no_compact_unwind. In other words, changing DARWIN_MINVERSION_SPEC / %(darwin_minversion) to say 10.6 causes GCC to run with a split personality, where some parts thinks it's 10.4 and others thinks it's 10.6. 

In order to solve this, either a lot of spec logics needs to be changed, or the -mmacosx-version-min argument needs to be "faked". This is actually done when the environment variable MACOSX_DEPLOYMENT_TARGET is found - but not when cross compiling. Any good reason for this? 

Also, it seems to me that DARWIN_MINVERSION_SPEC / %(darwin_minversion) is not that useful, when most of the specs are checking the -mmacosx-version-min argument anyway. 

The patch from gkeating (https://gcc.gnu.org/ml/gcc-patches/2007-02/msg01484.html) had the explicit goal of "fix or avoid a bunch of bugs where one part or another of the toolchain differed from the compiler in the minimum system version to be targetted.", but this is exactly the problem we are seeing here, thus I believe some additional work is required.
Comment 1 Peter Åstrand 2015-03-03 08:31:45 UTC
Created attachment 34933 [details]
Activate parts of darwin_default_min_version() even when not cross

The attached patch activates darwin_default_min_version() even when CROSS_DIRECTORY_STRUCTURE, and if MACOSX_DEPLOYMENT_TARGET is set, it falls back to a hardcoded 10.6 default. This solves our particular problem, but some additional work would be required to make e generic solution. For example, perhaps the fallback should be based on expanding %(darwin_minversion), or perhaps the default target kan be fetched from the SDK file tree?
Comment 2 Eric Gallager 2017-07-19 22:11:26 UTC
Could you please attach a testcase that fails without your patch, and passes after your patch is applied? Marking as WAITING until there is a clearer recipe to reproduce this bug.
Comment 3 Eric Gallager 2017-09-16 17:07:47 UTC
(In reply to Eric Gallager from comment #2)
> Could you please attach a testcase that fails without your patch, and passes
> after your patch is applied? Marking as WAITING until there is a clearer
> recipe to reproduce this bug.

(also you should send your patch from comment #1 to the gcc-patches mailing list, too; it's liable to get lost here)
Comment 4 Eric Gallager 2017-12-21 10:05:28 UTC
Closing due to lack of a testcase; feel free to reopen if you have one, or if you send the patch to the gcc-patches mailing list