Skip to content

Commit 5a494af

Browse files
oma: remove useless nolto workaround for loongarch64_nosimd
Signed-off-by: Ilikara <[email protected]>
1 parent dcbc9d9 commit 5a494af

File tree

3 files changed

+62
-63
lines changed

3 files changed

+62
-63
lines changed

app-admin/oma/autobuild/defines

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@ PKGREP="mirrormgr<=0.11.1"
1010

1111
USECLANG=1
1212
PKGESS=1
13-
14-
# FIXME: LTO will cause unexpected lsx generation
15-
NOLTO__LOONGARCH64_NOSIMD=1

app-admin/oma/spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VER=1.20.1
2-
REL=1
2+
REL=2
33
SRCS="git::commit=tags/v${VER/\~/-}::https://github.com/AOSC-Dev/oma"
44
CHKSUMS="SKIP"
55
CHKUPDATE="anitya::id=328412"
Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,78 @@
1-
From 3f3b1288db7f4e21337ddfa107e42211dafebee0 Mon Sep 17 00:00:00 2001
1+
From 874b53e68456b421b3a0bf7e2f48a2390758e71d Mon Sep 17 00:00:00 2001
22
From: WANG Rui <[email protected]>
33
Date: Wed, 3 Sep 2025 11:34:15 +0800
44
Subject: [PATCH 4/4] compiler: Apply target features to the entry function
55

66
---
7-
compiler/rustc_codegen_gcc/src/context.rs | 4 ++++
8-
compiler/rustc_codegen_llvm/src/context.rs | 10 ++++++++++
9-
compiler/rustc_codegen_ssa/src/base.rs | 1 +
10-
compiler/rustc_codegen_ssa/src/traits/misc.rs | 2 ++
11-
4 files changed, 17 insertions(+)
7+
compiler/rustc_codegen_llvm/src/attributes.rs | 21 ++++++++++++-------
8+
compiler/rustc_codegen_llvm/src/context.rs | 8 +++++--
9+
2 files changed, 20 insertions(+), 9 deletions(-)
1210

13-
diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs
14-
index ff141ad365..bf873cd156 100644
15-
--- a/compiler/rustc_codegen_gcc/src/context.rs
16-
+++ b/compiler/rustc_codegen_gcc/src/context.rs
17-
@@ -489,6 +489,10 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
18-
// TODO(antoyo)
19-
}
11+
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
12+
index adb53e0b66..3313b1f4c4 100644
13+
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
14+
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
15+
@@ -302,6 +302,19 @@ pub(crate) fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu
16+
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
17+
}
2018

21-
+ fn apply_target_features(&self, _llfn: Function<'gcc>) {
22-
+ // TODO(antoyo)
23-
+ }
19+
+/// Get the `target-features` LLVM attribute.
20+
+pub(crate) fn target_features_attr<'ll>(
21+
+ cx: &CodegenCx<'ll, '_>,
22+
+ function_features: Vec<String>,
23+
+) -> Option<&'ll Attribute> {
24+
+ let global_features = cx.tcx.global_backend_features(()).iter().map(String::as_str);
25+
+ let function_features = function_features.iter().map(String::as_str);
26+
+ let target_features =
27+
+ global_features.chain(function_features).intersperse(",").collect::<String>();
28+
+ (!target_features.is_empty())
29+
+ .then(|| llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features))
30+
+}
2431
+
25-
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> {
26-
let entry_name = self.sess().target.entry_name.as_ref();
27-
if !self.functions.borrow().contains_key(entry_name) {
32+
/// Get the `NonLazyBind` LLVM attribute,
33+
/// if the codegen options allow skipping the PLT.
34+
pub(crate) fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
35+
@@ -535,13 +548,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
36+
}
37+
}
38+
39+
- let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());
40+
- let function_features = function_features.iter().map(|s| s.as_str());
41+
- let target_features: String =
42+
- global_features.chain(function_features).intersperse(",").collect();
43+
- if !target_features.is_empty() {
44+
- to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
45+
- }
46+
+ to_add.extend(target_features_attr(cx, function_features));
47+
48+
attributes::apply_to_llfn(llfn, Function, &to_add);
49+
}
2850
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
29-
index 0324dff6ff..029855700d 100644
51+
index 0324dff6ff..55d335923d 100644
3052
--- a/compiler/rustc_codegen_llvm/src/context.rs
3153
+++ b/compiler/rustc_codegen_llvm/src/context.rs
32-
@@ -819,6 +819,16 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
33-
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &attrs);
34-
}
35-
36-
+ fn apply_target_features(&self, llfn: &'ll Value) {
37-
+ let mut attrs = SmallVec::<[_; 2]>::new();
38-
+ let global_features = self.tcx.global_backend_features(()).iter().map(|s| s.as_str());
39-
+ let target_features: String = global_features.intersperse(",").collect();
40-
+ if !target_features.is_empty() {
41-
+ attrs.push(llvm::CreateAttrStringValue(self.llcx, "target-features", &target_features));
42-
+ }
43-
+ attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &attrs);
44-
+ }
45-
+
54+
@@ -822,7 +822,7 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
4655
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function> {
4756
let entry_name = self.sess().target.entry_name.as_ref();
4857
if self.get_declared_value(entry_name).is_none() {
49-
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs
50-
index a3d6c73ba8..9b1a734c6b 100644
51-
--- a/compiler/rustc_codegen_ssa/src/base.rs
52-
+++ b/compiler/rustc_codegen_ssa/src/base.rs
53-
@@ -546,6 +546,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
54-
// `main` should respect same config for frame pointer elimination as rest of code
55-
cx.set_frame_pointer_type(llfn);
56-
cx.apply_target_cpu_attr(llfn);
57-
+ cx.apply_target_features(llfn);
58-
59-
let llbb = Bx::append_block(cx, llfn, "top");
60-
let mut bx = Bx::build(cx, llbb);
61-
diff --git a/compiler/rustc_codegen_ssa/src/traits/misc.rs b/compiler/rustc_codegen_ssa/src/traits/misc.rs
62-
index 710fab2790..24218d4ed0 100644
63-
--- a/compiler/rustc_codegen_ssa/src/traits/misc.rs
64-
+++ b/compiler/rustc_codegen_ssa/src/traits/misc.rs
65-
@@ -23,6 +23,8 @@ pub trait MiscCodegenMethods<'tcx>: BackendTypes {
66-
fn sess(&self) -> &Session;
67-
fn set_frame_pointer_type(&self, llfn: Self::Function);
68-
fn apply_target_cpu_attr(&self, llfn: Self::Function);
69-
+ /// Apply global target features to a given LLVM function.
70-
+ fn apply_target_features(&self, llfn: Self::Function);
71-
/// Declares the extern "C" main function for the entry point. Returns None if the symbol
72-
/// already exists.
73-
fn declare_c_main(&self, fn_type: Self::Type) -> Option<Self::Function>;
58+
- Some(self.declare_entry_fn(
59+
+ let llfn = self.declare_entry_fn(
60+
entry_name,
61+
llvm::CallConv::from_conv(
62+
self.sess().target.entry_abi,
63+
@@ -830,7 +830,11 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
64+
),
65+
llvm::UnnamedAddr::Global,
66+
fn_type,
67+
- ))
68+
+ );
69+
+ if let Some(attr) = attributes::target_features_attr(self, vec![]) {
70+
+ attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[attr])
71+
+ }
72+
+ Some(llfn)
73+
} else {
74+
// If the symbol already exists, it is an error: for example, the user wrote
75+
// #[no_mangle] extern "C" fn main(..) {..}
7476
--
7577
2.51.0
7678

0 commit comments

Comments
 (0)