This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Respect CMAKE_C_FLAGS when building builtins in-tree
AbandonedPublic

Authored by broadwaylamb on Aug 23 2019, 5:57 AM.

Details

Summary

This allows to provide flags in the top-level CMake invocation for specifying e. g. a target processor to build builtins for, like this:

cmake -DBUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=-mcpu=cortex-a15" ../llvm

Event Timeline

broadwaylamb created this revision.Aug 23 2019, 5:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2019, 5:57 AM
Herald added subscribers: Restricted Project, mgorny, dberris. · View Herald Transcript

Im not sure if this works. This sets the flags from the global flags, which may not be what we want as compiler-rt can be built as part of llvm itself.

broadwaylamb added a comment.EditedAug 23 2019, 1:49 PM

Im not sure if this works. This sets the flags from the global flags, which may not be what we want as compiler-rt can be built as part of llvm itself.

Building builtins as part of LLVM itself is exactly what I’m trying to accomplish. But it turns out there was no way to specify C flags just for builtins from the LLVM cmake invocation, which is what I’ve attempted to address here.

The global CMAKE_C_FLAGS will not be caught by builtins with this change simply because they won’t be passed to the “nested” CMake invocation. Instead, to specify CMAKE_C_FLAGS for builtins, you’ll need to pass them like this: -DBUILTINS_CMAKE_ARGS="-DCMAKE_C_FLAGS=..." when building LLVM.

This is assuming I got this whole CMake thing right (this is only my second contribution to LLVM). If not, I would appreciate any advice on how to pass C flags to builtins when building them as part of LLVM.

broadwaylamb abandoned this revision.Jan 10 2020, 5:34 AM