This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Driver] Use full path to builtins in bare-metal toolchain
AbandonedPublic

Authored by tambre on Aug 31 2020, 8:29 AM.

Details

Reviewers
phosek
Summary

The bare-metal toolchain ought to use full paths to link the builtins
bringing it in line with everything else.
Getting the path is now done through the getCompilerRT() function, which was
intended to be overriden in this manner.

Notably per-target runtime directories don't make sense for this toolchain,
so they aren't handled.

Related tests are updated to reference RESOURCE_DIR for their checks.
This patch is a revival of D59425.

Diff Detail

Event Timeline

tambre created this revision.Aug 31 2020, 8:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2020, 8:29 AM
tambre requested review of this revision.Aug 31 2020, 8:29 AM
tambre updated this revision to Diff 288956.Aug 31 2020, 8:32 AM

Add missing dash.

This was discussed when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR was introduced and there was a pushback against changing the driver behavior depending on the value of that option, so if we're going to reverse that decision for BareMetal, I think that deserves a broader discussion.

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

Is there a reason why BareMetal doesn't just use https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChain.cpp#L462 like all other drivers, and instead re-implements the runtime library lookup logic?

tambre updated this revision to Diff 289085.Sep 1 2020, 12:02 AM

Remove define to change driver behaviour, use ToolChain::getCompilerRTArgString() instead.

phosek accepted this revision.Sep 1 2020, 12:55 AM

LGTM

This revision is now accepted and ready to land.Sep 1 2020, 12:55 AM

This was discussed when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR was introduced and there was a pushback against changing the driver behavior depending on the value of that option, so if we're going to reverse that decision for BareMetal, I think that deserves a broader discussion.

Thanks for the background. I'd rather not go for a compile-time behaviour change in that case and have gone with using getCompilerRTArgString(). I'll do an internal toolchain build and do some testing before landing this.

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

Was unaware of that function before, thanks!
I can't see a good reason not to use it, so I've switched it over.

tambre updated this revision to Diff 289161.Sep 1 2020, 7:13 AM

Rework patch to simply cleanup runtime handling in the bare-metal toolchain.

tambre retitled this revision from [Clang][Driver] Support per-target runtime directories in the bare-metal toolchain to [Clang][Driver] Use full path to builtins in bare-metal toolchain.Sep 1 2020, 7:13 AM
tambre edited the summary of this revision. (Show Details)
tambre added a comment.Sep 1 2020, 7:16 AM

@phosek Please review again.
I've overhauled the patch as I realized that per-target runtime directories don't make sense for the bare-metal target, since the runtime is only distinguished by the specific architecture and nothing else.
As a result I've simply changed this into a cleanup doing the same thing as D59425, which seems to have languished.

tambre added a comment.Sep 7 2020, 9:57 AM

phosek: ping

phosek added a comment.Sep 8 2020, 7:46 PM

It's not clear why couldn't we support per-target runtime directory? It uses the standard multiarch layout, so in you'd end up using a directory like [path/to/resource-dir]/lib/armv6m-unknown-eabi/libclang_rt.builtins.a. I'd find this more preferable for consistency with other targets, it'd also enable the use of runtimes build for baremetal.

tambre abandoned this revision.Sep 11 2020, 11:22 AM

It's not clear why couldn't we support per-target runtime directory? It uses the standard multiarch layout, so in you'd end up using a directory like [path/to/resource-dir]/lib/armv6m-unknown-eabi/libclang_rt.builtins.a. I'd find this more preferable for consistency with other targets, it'd also enable the use of runtimes build for baremetal.

Agreed. Unfortunately I'm unable to actually get the builtins built for baremetal and I originally encountered this issue under circumstances I can no longer reproduce.
Abandoning this as a result. Hopefully someone else will be able to take it up.