This is an archive of the discontinued LLVM Phabricator instance.

MC: Don't emit min version directives when -fno-integrated-as is on
Needs ReviewPublic

Authored by majnemer on Nov 22 2014, 9:29 AM.

Details

Reviewers
grosbach
Summary

The assembler included with cctools doesn't understand
.macosx_version_min. We shouldn't try to emit that directive if we
aren't going to use the integrated assembler.

This fixes PR21636.

Diff Detail

Event Timeline

majnemer updated this revision to Diff 16527.Nov 22 2014, 9:29 AM
majnemer retitled this revision from to MC: Don't emit min version directives when -fno-integrated-as is on.
majnemer updated this object.
majnemer added a reviewer: grosbach.
majnemer added a subscriber: Unknown Object (MLST).

I believe we've been trying to avoid special casing the integrated
assembler as much as possible (I think Rafael removed many instances of
this) - any other signal that would be appropriate to use?

In D6371#4, @dblaikie wrote:

I believe we've been trying to avoid special casing the integrated
assembler as much as possible (I think Rafael removed many instances of
this) - any other signal that would be appropriate to use?

This patch is working around a directive which the cctools assembler does not have. Asking it to trigger on another condition would essentially be a proxy for "MC is targeting the cctools assembler" anyway.

In D6371#6, @majnemer wrote:
In D6371#4, @dblaikie wrote:

I believe we've been trying to avoid special casing the integrated
assembler as much as possible (I think Rafael removed many instances of
this) - any other signal that would be appropriate to use?

This patch is working around a directive which the cctools assembler does not have. Asking it to trigger on another condition would essentially be a proxy for "MC is targeting the cctools assembler" anyway.

Could we do this down in the MCStreamer instead?

It looks like MCAsmStreamer::EmitVersionMin should just be a no-op, maybe? (or a no-op on Darwin? Is the version directive valid anywhere else other than LLVM's integrated assembler?)

In D6371#7, @dblaikie wrote:
In D6371#6, @majnemer wrote:
In D6371#4, @dblaikie wrote:

I believe we've been trying to avoid special casing the integrated
assembler as much as possible (I think Rafael removed many instances of
this) - any other signal that would be appropriate to use?

This patch is working around a directive which the cctools assembler does not have. Asking it to trigger on another condition would essentially be a proxy for "MC is targeting the cctools assembler" anyway.

Could we do this down in the MCStreamer instead?

It looks like MCAsmStreamer::EmitVersionMin should just be a no-op, maybe? (or a no-op on Darwin?

How would we be able to emit the version information for Darwin if it were a no-op? I might be missing something but it sounds like .ios_version_min and .macosx_version_min would not properly round-trip.

Is the version directive valid anywhere else other than LLVM's integrated assembler?)

AFAIK, only the LLVM integrated assembler understands .ios_version_min and .macosx_version_min. I've checked the cctools sources and the latest binutils GAS sources as well.

grosbach edited edge metadata.Nov 22 2014, 5:35 PM

The non integrated assembler can't handle lots of things the compiler emits on Darwin. The only realistic use of that command line option now is when processing .s files.

Sent from my iPad

The cctools assembler is not supported. We should not do this.

FWIW, cctools' as doesn't understand .cfi_startproc et al either, so even if we did this, we'd barf over those. While this single case is quite trivial, I could see this snowballing messily elsewhere. =/

thakis added a subscriber: thakis.Jan 21 2015, 9:36 PM

I'm trying to use afl-fuzz with asan on OS X. afl-fuzz tells you to set CXX to afl-clang++ and rebuild your program. afl-clang++ then calls clang++ with -no-integrated-as and -B to a path with its own as wrapper that inserts some instrumentation assembly before calling real as. This doesn't work on OS X because clang++ writes this .macosx_version_min directive that as doesn't support. If I apply this patch, everything does work. So this seems like a useful thing to me – are there any downsides to this patch?

Are there any other possible fixes for this use-case? Does llvm have an as-compatible assembler driver somewhere?