[Hexagon] Enable init_arrays when target is linux-musl
authorSid Manning <sidneym@quicinc.com>
Thu, 12 Mar 2020 17:18:35 +0000 (12:18 -0500)
committerSid Manning <sidneym@quicinc.com>
Thu, 12 Mar 2020 20:00:15 +0000 (15:00 -0500)
Differential Revision: https://reviews.llvm.org/D76079

clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c

index 1e2e7c8..4a5e825 100644 (file)
@@ -544,7 +544,8 @@ unsigned HexagonToolChain::getOptimizationLevel(
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
                                              ArgStringList &CC1Args,
                                              Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = getTriple().isMusl();
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
                           options::OPT_fno_use_init_array,
index 93c9da2..fba1a89 100644 (file)
 // CHECK089:       "/hexagon{{/|\\\\}}lib{{/|\\\\}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// -----------------------------------------------------------------------------
+// Not Passing -fno-use-init-array when musl is selected
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:          -fno-use-init-array
+// -----------------------------------------------------------------------------