This is an archive of the discontinued LLVM Phabricator instance.

fixes compiler-rt bug when printing libgcc for baremetal
ClosedPublic

Authored by cjdb on Oct 13 2020, 9:34 AM.

Details

Summary

compiler-rt used to print /path/to/lib/clang/version/lib/libclang_rt.builtins-arm.a but should print /path/to/lib/clang/version/lib/baremetal/libclang_rt.builtins-arm.a.

Diff Detail

Event Timeline

cjdb created this revision.Oct 13 2020, 9:34 AM
cjdb requested review of this revision.Oct 13 2020, 9:34 AM
manojgupta added inline comments.Oct 13 2020, 10:18 AM
clang/include/clang/Driver/ToolChain.h
662–664

I think with some overrides in Baremetal driver, this should hopefully not be needed.

clang/lib/Driver/ToolChain.cpp
401

Can you implement this function in BareMetal toolchain driver. My understanding is this is already a virtual function so implementing it there is better to override the default location.

clang/lib/Driver/ToolChains/BareMetal.cpp
40

Please add function Stringref getOSLibName() to override the default. It should return "baremetal"

67

Please add a getCompilerRTPath function which will call BareMetal::getRuntimesDir and to override ToolChain's getCompilerRTPath behavior.

163

Please implement getCompilerRTBasename function that just returns the part "clang_rt.builtins-" + getTriple().getArchName())" and call it here.

getCompilerRTBasename may need to be made virtual in Toolchain class so that it will override ToolChain class's default implementation.

manojgupta added inline comments.Oct 13 2020, 10:46 AM
clang/lib/Driver/ToolChains/BareMetal.cpp
163

Actually instead of implementing getCompilerRTBasename , just adding getArchNameForCompilerRTLib function is probably enough.

Make getArchNameForCompilerRTLib function in Toolchain.cpp part of Toolchain class and make it virtual.

Then overriding getArchNameForCompilerRTLib in BareMetal.h/.cpp by "return getTriple().getArchName()" is just what we need.

cjdb updated this revision to Diff 297924.Oct 13 2020, 11:30 AM
cjdb marked 3 inline comments as done.

Applies @manojgupta's requests.

clang/lib/Driver/ToolChains/BareMetal.cpp
163

Done, needed to prepend "lib" as well.

manojgupta accepted this revision.Oct 13 2020, 12:53 PM
manojgupta added inline comments.
clang/lib/Driver/ToolChains/BareMetal.cpp
163

Thanks, overriding getArchNameForCompilerRTLib probably makes the change too large. We can revisit this in future if needed.

This revision is now accepted and ready to land.Oct 13 2020, 12:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2020, 10:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript