Fix OSX build failure from latest XCode update.

To begin with, the toolchain no longer lets me build for x86-32 -
apparently MacOS is now 64-bit only.

Also, the linker now gives an error about a missing libgcc_s variant
for -mmacosx-version-min=10.4, and indeed 10.5. So I've bumped the
minimum supported OS version to 10.6.

That in turn required some changes in osx.m itself, because bumping
the min OS version caused some API deprecations to show up. Luckily I
turned out to have left myself a comment some time ago telling me what
I was going to need to do about one of them :-)
This commit is contained in:
Simon Tatham
2018-10-06 18:22:42 +01:00
parent d8d506455e
commit f281644b0b
2 changed files with 10 additions and 25 deletions

View File

@ -1707,7 +1707,8 @@ if (defined $makefiles{'nestedvm'}) {
if (defined $makefiles{'osx'}) { if (defined $makefiles{'osx'}) {
$mftyp = 'osx'; $mftyp = 'osx';
$dirpfx = &dirpfx($makefiles{'osx'}, "/"); $dirpfx = &dirpfx($makefiles{'osx'}, "/");
@osxarchs = ('i386', 'x86_64'); @osxarchs = ('x86_64');
my $osxminver = "10.6";
##-- Mac OS X makefile ##-- Mac OS X makefile
open OUT, ">$makefiles{'osx'}"; select OUT; open OUT, ">$makefiles{'osx'}"; select OUT;
@ -1756,7 +1757,7 @@ if (defined $makefiles{'osx'}) {
foreach $arch (@osxarchs) { foreach $arch (@osxarchs) {
$objstr = &objects($p, "X.${arch}.o", undef, undef); $objstr = &objects($p, "X.${arch}.o", undef, undef);
print &splitline("${prog}.${arch}.bin: " . $objstr), "\n"; print &splitline("${prog}.${arch}.bin: " . $objstr), "\n";
print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(LDFLAGS) -o \$@ " . print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=${osxminver} \$(LDFLAGS) -o \$@ " .
$objstr . " $libstr", 69), "\n\n"; $objstr . " $libstr", 69), "\n\n";
$archbins .= " ${prog}.${arch}.bin"; $archbins .= " ${prog}.${arch}.bin";
} }
@ -1771,7 +1772,7 @@ if (defined $makefiles{'osx'}) {
foreach $arch (@osxarchs) { foreach $arch (@osxarchs) {
$objstr = &objects($p, "X.${arch}.o", undef, undef); $objstr = &objects($p, "X.${arch}.o", undef, undef);
print &splitline("${prog}.${arch}: " . $objstr), "\n"; print &splitline("${prog}.${arch}: " . $objstr), "\n";
print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=10.4 \$(ULDFLAGS) -o \$@ " . print &splitline("\t\$(CC) -arch ${arch} -mmacosx-version-min=${osxminver} \$(ULDFLAGS) -o \$@ " .
$objstr . " $libstr", 69), "\n\n"; $objstr . " $libstr", 69), "\n\n";
$archbins .= " ${prog}.${arch}"; $archbins .= " ${prog}.${arch}";
} }
@ -1784,10 +1785,10 @@ if (defined $makefiles{'osx'}) {
"\n"; "\n";
$deflist = join "", map { " -D$_" } @{$d->{defs}}; $deflist = join "", map { " -D$_" } @{$d->{defs}};
if ($d->{deps}->[0] =~ /\.m$/) { if ($d->{deps}->[0] =~ /\.m$/) {
print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)". print "\t\$(CC) -arch $arch -mmacosx-version-min=${osxminver} -x objective-c \$(COMPAT) \$(FWHACK) \$(CFLAGS)".
" \$(XFLAGS)$deflist -c \$< -o \$\@\n"; " \$(XFLAGS)$deflist -c \$< -o \$\@\n";
} else { } else {
print "\t\$(CC) -arch $arch -mmacosx-version-min=10.4 \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" . print "\t\$(CC) -arch $arch -mmacosx-version-min=${osxminver} \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist" .
" -c \$< -o \$\@\n"; " -c \$< -o \$\@\n";
} }
} }

24
osx.m
View File

@ -750,7 +750,7 @@ struct frontend {
NSSavePanel *sp = [NSSavePanel savePanel]; NSSavePanel *sp = [NSSavePanel savePanel];
if ([sp runModal] == NSFileHandlingPanelOKButton) { if ([sp runModal] == NSFileHandlingPanelOKButton) {
const char *name = [[sp filename] UTF8String]; const char *name = [[sp URL] fileSystemRepresentation];
FILE *fp = fopen(name, "w"); FILE *fp = fopen(name, "w");
@ -770,25 +770,9 @@ struct frontend {
[op setAllowsMultipleSelection:NO]; [op setAllowsMultipleSelection:NO];
if ([op runModalForTypes:nil] == NSOKButton) { if ([op runModal] == NSOKButton) {
/* const char *name = [[[op URLs] objectAtIndex:0]
* This used to be fileSystemRepresentation];
*
* [[[op filenames] objectAtIndex:0] cString]
*
* but the plain cString method became deprecated and Xcode 7
* started complaining about it. Since OS X 10.9 we can
* apparently use the more modern API
*
* [[[op URLs] objectAtIndex:0] fileSystemRepresentation]
*
* but the alternative below still compiles with Xcode 7 and
* is a bit more backwards compatible, so I'll try it for the
* moment.
*/
const char *name = [[[op filenames] objectAtIndex:0]
cStringUsingEncoding:
[NSString defaultCStringEncoding]];
const char *err; const char *err;
FILE *fp = fopen(name, "r"); FILE *fp = fopen(name, "r");