Skip to content

Commit

Permalink
This patch works around an issue with the new Clang front end in Xcod…
Browse files Browse the repository at this point in the history
…e 5.0. When passed an argument of '-x assembler', Clang seems to ignore all other arguments. This is a problem, because we have to pass Clang an argument of -no-integrated-as in order to make the libjpeg-turbo NEON code assemble correctly. Thus, this patch creates a temporary file and then calls system() to execute the assembler, rather than attempting to pass the filtered assembly code to the assembler via stdin. Note that we also now need to strip the various -M* options from the assembler command line, else the dependency file for the SIMD object will depend on the temporary assembly file (which is deleted after use) and not the original assembly file.

git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/gas-preprocessor@1103 632fc199-4ca6-4c93-a231-07263d6284db
  • Loading branch information
dcommander committed Jan 29, 2014
1 parent 76a72f0 commit f45b2b5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gas-preprocessor.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env perl
# by David Conrad
# modifications by D. R. Commander, Copyright (C)2013
# This code is licensed under GPLv2 or later; go to gnu.org to read it
# (not that it much matters for an asm preprocessor)
# usage: set your assembler to be something like "perl gas-preprocessor.pl gcc"
use strict;
use File::Temp qw(tempfile);

# Apple's gas is ancient and doesn't support modern preprocessing features like
# .rept and has ugly macro syntax, among other things. Thus, this script
Expand Down Expand Up @@ -45,7 +47,6 @@
}
}
}
@gcc_cmd = map { /\.[csS]$/ ? qw(-x assembler -) : $_ } @gcc_cmd;
@preprocess_c_cmd = map { /\.o$/ ? "-" : $_ } @preprocess_c_cmd;

my $comm;
Expand Down Expand Up @@ -367,10 +368,13 @@ sub expand_macros {
}

close(ASMFILE) or exit 1;
my $fh, my $filename;
if ($ENV{GASPP_DEBUG}) {
open(ASMFILE, ">&STDOUT");
} else {
open(ASMFILE, "|-", @gcc_cmd) or die "Error running assembler";
($fh, $filename) = tempfile("gas-preprocessor-tmp-XXXXXX", SUFFIX => '.S',
TMPDIR => 1, UNLINK => 1);
open(ASMFILE, ">" . $filename) or die "Error running assembler";
}

my @sections;
Expand Down Expand Up @@ -532,4 +536,10 @@ sub expand_macros {
grep exists $thumb_labels{$_}, keys %call_targets;

close(ASMFILE) or exit 1;

@gcc_cmd = map { /\.[csS]$/ ? $filename : $_ } @gcc_cmd;
@gcc_cmd = map { /\-M[DFPT]|\.lo|\.Tpo$/ ? "" : $_ } @gcc_cmd;
system @gcc_cmd;
$? == 0 or die "Error running assembler";

#exit 1

0 comments on commit f45b2b5

Please sign in to comment.