Page MenuHomePhabricator

[Driver] Support linking to compiler-rt for target AVR
AbandonedPublic

Authored by benshi001 on May 24 2022, 7:06 AM.

Details

Reviewers
aykevl
dylanmckay

Diff Detail

Event Timeline

benshi001 created this revision.May 24 2022, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 7:06 AM
Herald added subscribers: Jim, dberris. · View Herald Transcript
benshi001 requested review of this revision.May 24 2022, 7:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2022, 7:06 AM
benshi001 added inline comments.May 24 2022, 8:00 AM
clang/lib/Driver/ToolChains/AVR.cpp
463

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

482

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/
492

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

541

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

564

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

595

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

608

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.

It seems that the expected path should be $resource_dir/lib/avr5/libclang_rt.builtins.a, other than libclang_rt.builtins-avr5.a. I will fix that.

benshi001 added inline comments.Jun 1 2022, 1:41 AM
clang/lib/Driver/ToolChains/AVR.cpp
463

This override method is unnecessary, the basic ToolChain::buildCompilerRTBasename has covered all cases for AVR, since

  1. .lib suffix can never be generated for avr
  2. libclang_rt.builtins-avr5.a is unexpected, which should be `

$resource_dir/lib/avr5/libclang_rt.builtins.a`.

benshi001 abandoned this revision.Jun 7 2022, 12:22 AM