Page MenuHomePhabricator

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

Unit TestsFailed

TimeTest
480 msx64 debian > Clang Tools.clang-tidy/checkers::cppcoreguidelines-macro-usage-command-line-macros.cpp
Script: -- : 'RUN: at line 1'; /usr/bin/python3.8 /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -check-suffixes=NORMAL /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage-command-line-macros.cpp cppcoreguidelines-macro-usage /mnt/disks/ssd0/agent/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/Output/cppcoreguidelines-macro-usage-command-line-macros.cpp.tmp -- -- -D_ZZZ_IM_A_MACRO
30 msx64 debian > Clang Tools.pp-trace::pp-trace-include.cpp
Script: -- : 'RUN: at line 1'; pp-trace /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/pp-trace/pp-trace-include.cpp -- -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/pp-trace/pp-trace-include.cpp
30 msx64 debian > Clang Tools.pp-trace::pp-trace-macro.cpp
Script: -- : 'RUN: at line 1'; pp-trace -callbacks '*,-FileChanged' /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp -- -undef -target x86_64 -std=c++11 | FileCheck --strict-whitespace /mnt/disks/ssd0/agent/llvm-project/clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
20 msx64 debian > Clang-Unit.Frontend/_/FrontendTests::CommandLineTest.RoundTrip
Note: Google Test filter = CommandLineTest.RoundTrip [==========] Running 1 test from 1 test case. [----------] Global test environment set-up.
110 msx64 debian > Clang.CodeGen::debug-info-macro.c
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/13.0.0/include -nostdsysteminc -emit-llvm -debug-info-kind=line-tables-only -debug-info-macro /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/debug-info-macro.c -o - "-DC1(x)=( x + 5 )" -DA -include /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/Inputs/debug-info-macro.h -UC1 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck -check-prefixes=CHECK,NO_PCH /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/debug-info-macro.c
View Full Test Results (14 Failed)

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.

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)...