This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Support linking to compiler-rt on AVR
AbandonedPublic

Authored by benshi001 on Apr 12 2022, 8:03 AM.

Details

Diff Detail

Event Timeline

benshi001 created this revision.Apr 12 2022, 8:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 8:03 AM
benshi001 requested review of this revision.Apr 12 2022, 8:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 8:03 AM

As changes in https://reviews.llvm.org/D123200,
it whould be better to support "--rtlib=compiler-rt" on AVR first.

benshi001 updated this revision to Diff 422388.Apr 12 2022, 9:01 PM
benshi001 updated this revision to Diff 423366.Apr 18 2022, 6:15 AM
benshi001 added inline comments.May 6 2022, 7:28 PM
clang/lib/Driver/ToolChains/AVR.cpp
430

This method decides the file name of compiler-rt, it is expected to be

libclang_rt.builtins-avrfamily.a, such as

libclang_rt.builtins-avr51.a
libclang_rt.builtins-avrtiny.a
libclang_rt.builtins-avrxmega3.a

433

This method decides the library path of compiler-rt, it is
$(RESOURCE_DIR)/lib/avr or $(RESOURCE_DIR)/lib/. The resource dir is either explicitly specified via user option -resource-dir or has default value $(LLVM_INSTALL_DIR)/lib/clang/$(LLVM_VERSION. such as

/opt/avr-tool-chain/lib/clang/14.0.1/lib/avr
/opt/avr-tool-chain/lib/clang/14.0.1/lib/

444

Currently we still use libgcc if --rtlib option is not specified.

482

Currently we only allow --rtlib=libgcc and --rtlib=compiler-rt

510

If --rtlib is not specified or specified to libgcc, then we generate -L$PATH_TO_LIBGCC

550

If --rtlib is not specified or specified to libgcc, then we generate -lgcc

563

If --rtlib=compiler-rt is explicitly specified, we directly put the libclang.builtins-avrxxx.a as input file, other than -lclang.builtins-avrxxx, this is a tradition from other platforms, such as x86 and arm.

MaskRay added inline comments.May 6 2022, 9:45 PM
clang/lib/Driver/ToolChains/AVR.cpp
430

In -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on mode this should be lib/clang/$version/lib/$triple/libclang_rt.xxx.a where there is no -microarch infix.

benshi001 updated this revision to Diff 427821.May 7 2022, 12:15 AM
benshi001 added inline comments.May 7 2022, 12:18 AM
clang/lib/Driver/ToolChains/AVR.cpp
430

But I would expect each subarch has its own specific build with specific
optimization. That is the way in avr-gcc distribution.

benshi001 added inline comments.May 7 2022, 12:22 AM
clang/lib/Driver/ToolChains/AVR.cpp
430

This hook buildCompilerRTBasename with be called twice by the base class. The first time is called with AddArch = false, for which I do not append -microarch infix.

For the second call with AddArch = true, I will append -microarch infix.

ormris removed a subscriber: ormris.May 16 2022, 10:58 AM
benshi001 abandoned this revision.May 24 2022, 5:41 AM