This is an archive of the discontinued LLVM Phabricator instance.

Define __GCC_HAVE_DWARF2_CFI_ASM if applicable
ClosedPublic

Authored by MaskRay on Mar 1 2021, 4:08 PM.

Details

Summary

In -fno-exceptions -fno-asynchronous-unwind-tables -g0 mode,
GCC does not emit .cfi_* directives.

% diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c)
130a131
> #define __GCC_HAVE_DWARF2_CFI_ASM 1

This macro is useful because code can decide whether inline asm should include .cfi_* directives.
.cfi_* directives without .cfi_startproc can cause assembler errors.

Diff Detail

Event Timeline

MaskRay requested review of this revision.Mar 1 2021, 4:08 PM
MaskRay created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2021, 4:08 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay updated this revision to Diff 327320.Mar 1 2021, 4:37 PM
MaskRay retitled this revision from Define __GCC_HAVE_DWARF2_CFI_ASM to 1 on ELF/Mach-O if CC1 -munwind-tables is specified to Define __GCC_HAVE_DWARF2_CFI_ASM if applicable.
MaskRay edited the summary of this revision. (Show Details)

Check -g and exceptions

jansvoboda11 accepted this revision.Mar 9 2021, 4:16 AM

Could the logic be implemented in the driver?

LGTM regardless.

This revision is now accepted and ready to land.Mar 9 2021, 4:16 AM
MaskRay added a comment.EditedMar 9 2021, 10:32 AM

Could the logic be implemented in the driver?

LGTM regardless.

No. Res is a clang::CompilerInvocation object. CompilerInvocation is not in the driver... -D -U and __CET__ are implemented in this file, too.

This revision was landed with ongoing or failed builds.Mar 9 2021, 10:52 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Mar 9 2021, 11:56 AM

This seems to break tests everywhere: http://45.33.8.238/linux/41275/step_7.txt

Could the logic be implemented in the driver?

LGTM regardless.

No. Res is a clang::CompilerInvocation object. CompilerInvocation is not in the driver... -D -U and __CET__ are implemented in this file, too.

Right. I meant if it would be possible to move the logic to the driver and pass -D__GCC_HAVE_DWARF2_CFI_ASM=1 explicitly from the driver to -cc1, keeping CompilerInvocation as simple as possible.

MaskRay reopened this revision.Mar 9 2021, 12:38 PM
This revision is now accepted and ready to land.Mar 9 2021, 12:38 PM
MaskRay updated this revision to Diff 329441.Mar 9 2021, 12:38 PM

Move to driver

This revision was landed with ongoing or failed builds.Mar 9 2021, 10:21 PM
This revision was automatically updated to reflect the committed changes.

Move to driver

Thanks!

There are some side effects: because -D is passed as command line options, it has <command line> in its filename, so isWrittenInBuiltinFile will not match it (isWrittenInBuiltinFile can match other built-in macros)...