LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 48494 - ARM64 outline atomic helpers are built using the C compiler
Summary: ARM64 outline atomic helpers are built using the C compiler
Status: RESOLVED FIXED
Alias: None
Product: compiler-rt
Classification: Unclassified
Component: builtins (show other bugs)
Version: unspecified
Hardware: All All
: P release blocker
Assignee: Raul Tambre
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-12 03:30 PST by Raul Tambre
Modified: 2021-02-06 23:56 PST (History)
1 user (show)

See Also:
Fixed By Commit(s): d0797e62fa8a73ad75dcaca7c0e1a71c2001c855


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raul Tambre 2020-12-12 03:30:33 PST
Assembly files should not be compiled as C and instead use CMake's assembly language support to allow for vendors and users to specify flags, compiler options, use a different executable, have correct architecture flags, interact properly with toolchain files, etc.

The compiler-rt ARM64 outline atomic helpers are a new and the only case of this improper usage in the codebase.
It seems these should use the already-existing compiler-rt add_asm_sources() helper.

Previous occurrences of this were fixed by https://github.com/llvm/llvm-project/commit/45344cf7ac5b848f77825ffa37b0cb3b69b9b07b. The improper usage resulted in multiple reports from users and vendors, requiring a backport to resolve build issues.
It would be best to avoid a recurrence of the problems. Marking as a release blocker due to this.

Pavel, could you take a look at this?
Comment 1 Pavel Iliin 2020-12-13 05:37:01 PST
I am using just C preprocessor to generate outline atomic helpers from lse.S. Then generated assembly files are added to aarch64_SOURCES along with other asm (aarch64/chkstk.S for example) and С sources to compile. There are a lot of *.S files used as sources for compilation as well (see *_SOURCES in compiler-rt/lib/builtins/CMakeLists.txt). Could you clarify is it something APPLE specific and I should use add_asm_sources() in 'if (APPLE)' case?
Comment 2 Raul Tambre 2020-12-13 07:00:19 PST
> I am using just C preprocessor to generate outline atomic helpers from lse.S. Then generated assembly files are added to aarch64_SOURCES along with other asm (aarch64/chkstk.S for example) and С sources to compile. There are a lot of *.S files used as sources for compilation as well (see *_SOURCES in compiler-rt/lib/builtins/CMakeLists.txt).

Apologies, I should've read the code more carefully.

Nevertheless, passing CMAKE_C_FLAGS to the preprocessor isn't too good. In my case CMAKE_C_FLAGS contains processor-specific options (i.e. -mcpu=carmel) resulting in tons of warnings. I can imagine other vendors having options meant for compiling that will similarly result in warnings or even errors when only preprocessing.

Preprocessing separately seems unnecessary in addition to making things more fragile and complicated.
It seems it'd be simpler to simply symlink and compile each symlink with the definitions.

I went ahead and implemented that:
https://reviews.llvm.org/D93178

> Could you clarify is it something APPLE specific and I should use add_asm_sources() in 'if (APPLE)' case?

Nothing Apple-specific. The APPLE and MINGW cases in add_asm_sources() are to workaround ASM language bugs in older CMake versions on those platforms.