Skip to content

Commit f18cbc1

Browse files
committed
Darwin: Future-proof and homogeneize detection of darwin versions
The current GCC branch will become 12.1.0, which will be the stable version of GCC when the next macOS version is released. There are some places in GCC that don’t handle darwin22 as a version, so we need to future-proof it (gcc/config.gcc and gcc/config/darwin-driver.c). We align that code with what Apple clang does, i.e. accept all potential major macOS versions until 99. This patch also homogenises the handling of darwin version numbers, where the majority of places use darwin2*, but some used darwin2[0-9]*. Since there never was a darwin2.x version, the two are equivalent, and we prefer the simpler darwin2* gcc/ChangeLog: * config/darwin-driver.c: Make version code more future-proof. * config.gcc: Homogeneize darwin versions. * configure.ac: Homogeneize darwin versions. * configure: Regenerate. gcc/testsuite/ChangeLog: * gcc.dg/darwin-minversion-link.c: Test darwin21. * obj-c++.dg/cxx-ivars-3.mm: Homogeneize darwin versions. * obj-c++.dg/objc-gc-3.mm: Homogeneize darwin versions. * objc.dg/objc-gc-4.m: Homogeneize darwin versions.
1 parent 2554e2d commit f18cbc1

File tree

8 files changed

+12
-11
lines changed

8 files changed

+12
-11
lines changed

gcc/config.gcc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ hppa[12]*-*-hpux11*)
18471847
dwarf2=no
18481848
fi
18491849
;;
1850-
i[34567]86-*-darwin1[89]* | i[34567]86-*-darwin2[0-9]*)
1850+
i[34567]86-*-darwin1[89]* | i[34567]86-*-darwin2*)
18511851
echo "Error: 32bit target is not supported after Darwin17" 1>&2
18521852
;;
18531853
i[34567]86-*-darwin*)
@@ -1857,7 +1857,7 @@ i[34567]86-*-darwin*)
18571857
tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch t-slibgcc"
18581858
tm_file="${cpu_type}/darwin32-biarch.h ${tm_file} "
18591859
;;
1860-
x86_64-*-darwin1[89]* | x86_64-*-darwin2[01]*)
1860+
x86_64-*-darwin1[89]* | x86_64-*-darwin2*)
18611861
# Only 64b from now
18621862
tm_defines="${tm_defines} TARGET_64BIT_DEFAULT=(OPTION_MASK_ISA_64BIT|OPTION_MASK_ABI_64)"
18631863
tm_defines="${tm_defines} TARGET_BI_ARCH=0"

gcc/config/darwin-driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ validate_macosx_version_min (const char *version_str)
6464

6565
major = strtoul (version_str, &end, 10);
6666

67-
if (major < 10 || major > 12 ) /* macOS 10, 11, and 12 are known. */
67+
/* macOS 10, 11, and 12 are known. clang accepts up to 99. */
68+
if (major < 10 || major > 99)
6869
return NULL;
6970

7071
/* Skip a separating period, if there's one. */
@@ -160,8 +161,7 @@ darwin_find_version_from_kernel (void)
160161

161162
/* Darwin20 sees a transition to macOS 11. In this, it seems that the
162163
mapping to macOS minor version is now shifted to the kernel minor
163-
version - 1 (at least for the initial releases). At this stage, we
164-
don't know what macOS version will correspond to Darwin21. */
164+
version - 1 (at least for the initial releases). */
165165
if (major_vers >= 20)
166166
{
167167
int minor_vers = *version_p++ - '0';

gcc/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26947,7 +26947,7 @@ $as_echo "$as_me: WARNING: LTO for $target requires binutils >= 2.20.1, but vers
2694726947
;;
2694826948
esac
2694926949
case $target_os in
26950-
darwin2[0-9]* | darwin19*)
26950+
darwin2* | darwin19*)
2695126951
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for llvm assembler x86-pad-for-align option" >&5
2695226952
$as_echo_n "checking assembler for llvm assembler x86-pad-for-align option... " >&6; }
2695326953
if ${gcc_cv_as_mllvm_x86_pad_for_align+:} false; then :

gcc/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4692,7 +4692,7 @@ foo: nop
46924692
;;
46934693
esac
46944694
case $target_os in
4695-
darwin2[[0-9]]* | darwin19*)
4695+
darwin2* | darwin19*)
46964696
gcc_GAS_CHECK_FEATURE([llvm assembler x86-pad-for-align option],
46974697
gcc_cv_as_mllvm_x86_pad_for_align,
46984698
[-mllvm -x86-pad-for-align=false], [.text],,

gcc/testsuite/gcc.dg/darwin-minversion-link.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
/* { dg-additional-options "-mmacosx-version-min=010.013.06 -DCHECK=101306" { target *-*-darwin17* } } */
1616
/* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin18* } } */
1717
/* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { target *-*-darwin19* } } */
18-
/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20 } } */
18+
/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20* } } */
19+
/* { dg-additional-options "-mmacosx-version-min=012.000.00 -DCHECK=120000" { target *-*-darwin21* } } */
1920

2021
int
2122
main ()

gcc/testsuite/obj-c++.dg/cxx-ivars-3.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// { dg-do run { target *-*-darwin* } }
44
// { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } }
5-
// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[1-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } }
5+
// { dg-skip-if "Headers incompatible with 10.4 APIs" { *-*-darwin1[1-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } }
66
// { dg-additional-options "-fobjc-call-cxx-cdtors -mmacosx-version-min=10.4 -framework Foundation" }
77
// This test has no equivalent or meaning for m64/ABI V2
88
// { dg-xfail-run-if "No Test Avail" { *-*-darwin* && lp64 } { "-fnext-runtime" } { "" } }

gcc/testsuite/obj-c++.dg/objc-gc-3.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* Contributed by Ziemowit Laski <[email protected]> */
44

55
/* { dg-do compile } */
6-
/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } } */
6+
/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } } */
77
/* { dg-options "-fobjc-gc" } */
88
/* { dg-prune-output "cc1objplus: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */
99

gcc/testsuite/objc.dg/objc-gc-4.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* Contributed by Ziemowit Laski <[email protected]> */
44

55
/* { dg-do compile } */
6-
/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2[0-9]* } { "-fnext-runtime" } { "" } } */
6+
/* { dg-skip-if "GC API is an error from Darwin16." { *-*-darwin1[6-9]* *-*-darwin2* } { "-fnext-runtime" } { "" } } */
77
/* { dg-options "-fobjc-gc" } */
88
/* { dg-prune-output "cc1obj: warning: '-fobjc-gc' is ignored for '-fgnu-runtime'" } */
99

0 commit comments

Comments
 (0)