File tree Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -741,16 +741,28 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
741741 case llvm::Triple::loongarch32:
742742 switch (os) {
743743 case llvm::Triple::Linux:
744- return std::make_unique<LinuxTargetInfo<LoongArch32TargetInfo>>(Triple,
745- Opts);
744+ switch (Triple.getEnvironment ()) {
745+ default :
746+ return std::make_unique<LinuxTargetInfo<LoongArch32TargetInfo>>(Triple,
747+ Opts);
748+ case llvm::Triple::OpenHOS:
749+ return std::make_unique<OHOSTargetInfo<LoongArch32TargetInfo>>(Triple,
750+ Opts);
751+ }
746752 default :
747753 return std::make_unique<LoongArch32TargetInfo>(Triple, Opts);
748754 }
749755 case llvm::Triple::loongarch64:
750756 switch (os) {
751757 case llvm::Triple::Linux:
752- return std::make_unique<LinuxTargetInfo<LoongArch64TargetInfo>>(Triple,
753- Opts);
758+ switch (Triple.getEnvironment ()) {
759+ default :
760+ return std::make_unique<LinuxTargetInfo<LoongArch64TargetInfo>>(Triple,
761+ Opts);
762+ case llvm::Triple::OpenHOS:
763+ return std::make_unique<OHOSTargetInfo<LoongArch64TargetInfo>>(Triple,
764+ Opts);
765+ }
754766 case llvm::Triple::FreeBSD:
755767 return std::make_unique<FreeBSDTargetInfo<LoongArch64TargetInfo>>(Triple,
756768 Opts);
Original file line number Diff line number Diff line change @@ -2458,7 +2458,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
24582458
24592459 static const char *const LoongArch64LibDirs[] = {" /lib64" , " /lib" };
24602460 static const char *const LoongArch64Triples[] = {
2461- " loongarch64-linux-gnu" , " loongarch64-unknown-linux-gnu" };
2461+ " loongarch64-linux-gnu" , " loongarch64-unknown-linux-gnu" ,
2462+ " loongarch64-linux-ohos" };
24622463
24632464 static const char *const M68kLibDirs[] = {" /lib" };
24642465 static const char *const M68kTriples[] = {" m68k-unknown-linux-gnu" ,
Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ std::string OHOS::getMultiarchTriple(const llvm::Triple &T) const {
111111 return " x86_64-linux-ohos" ;
112112 case llvm::Triple::aarch64:
113113 return " aarch64-linux-ohos" ;
114+ case llvm::Triple::loongarch64:
115+ return " loongarch64-linux-ohos" ;
114116 }
115117 return T.str ();
116118}
@@ -368,7 +370,12 @@ void OHOS::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
368370 CmdArgs.push_back (" -z" );
369371 CmdArgs.push_back (" relro" );
370372 CmdArgs.push_back (" -z" );
371- CmdArgs.push_back (" max-page-size=4096" );
373+ // LoongArch needs page size 16K
374+ if (getArch () == llvm::Triple::loongarch64) {
375+ CmdArgs.push_back (" max-page-size=16384" );
376+ } else {
377+ CmdArgs.push_back (" max-page-size=4096" );
378+ }
372379 // .gnu.hash section is not compatible with the MIPS target
373380 if (getArch () != llvm::Triple::mipsel)
374381 CmdArgs.push_back (" --hash-style=both" );
Original file line number Diff line number Diff line change 33// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=riscv64-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=RISCV64-OHOS-CXX
44// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=mipsel-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=MIPSEL-OHOS-CXX
55// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=X86_64-OHOS-CXX
6+ // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=loongarch64-linux-ohos < /dev/null | FileCheck %s -match-full-lines -check-prefix=LOONGARCH64-OHOS-CXX
67// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-linux-ohos < /dev/null | FileCheck %s -check-prefix=OHOS-DEFS
78
89// ARM-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
910// ARM64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
1011// RISCV64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
1112// MIPSEL-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
1213// X86_64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
14+ // LOONGARCH64-OHOS-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
1315// OHOS-DEFS: __OHOS_FAMILY__
1416// OHOS-DEFS: __OHOS__
1517// OHOS-DEFS-NOT: __OHOS__
You can’t perform that action at this time.
0 commit comments