Skip to content

Commit 6174fdd

Browse files
committed
[Hexagon] Enable init_arrays when target is linux-musl
Differential Revision: https://reviews.llvm.org/D76079
1 parent 4e589e6 commit 6174fdd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Driver/ToolChains/Hexagon.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ unsigned HexagonToolChain::getOptimizationLevel(
544544
void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
545545
ArgStringList &CC1Args,
546546
Action::OffloadKind) const {
547-
bool UseInitArrayDefault = false;
547+
548+
bool UseInitArrayDefault = getTriple().isMusl();
548549

549550
if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
550551
options::OPT_fno_use_init_array,

clang/test/Driver/hexagon-toolchain-elf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,13 @@
664664
// CHECK089: "/hexagon{{/|\\\\}}lib{{/|\\\\}}crt1.o"
665665
// CHECK089-NOT: -lclang_rt.builtins-hexagon
666666
// CHECK089-NOT: -lc
667+
// -----------------------------------------------------------------------------
668+
// Not Passing -fno-use-init-array when musl is selected
669+
// -----------------------------------------------------------------------------
670+
// RUN: %clang -### -target hexagon-unknown-linux-musl \
671+
// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
672+
// RUN: -mcpu=hexagonv60 \
673+
// RUN: %s 2>&1 \
674+
// RUN: | FileCheck -check-prefix=CHECK090 %s
675+
// CHECK090-NOT: -fno-use-init-array
676+
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)