From d6ee437f947de4cc01d02459da34eff8aa1653fd Mon Sep 17 00:00:00 2001 From: Reilly Brogan Date: Fri, 7 Jun 2024 15:08:30 -0500 Subject: [PATCH] rust: Add RUSTFLAGS Signed-off-by: Reilly Brogan --- ypkg2/scripts.py | 2 ++ ypkg2/ypkgcontext.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ypkg2/scripts.py b/ypkg2/scripts.py index 97ec486..79c104f 100644 --- a/ypkg2/scripts.py +++ b/ypkg2/scripts.py @@ -122,6 +122,7 @@ def init_default_macros(self): self.define_macro("CFLAGS", " ".join(self.context.build.cflags)) self.define_macro("CXXFLAGS", " ".join(self.context.build.cxxflags)) self.define_macro("LDFLAGS", " ".join(self.context.build.ldflags)) + self.define_macro("RUSTFLAGS", " ".join(self.context.build.rustflags)) self.define_macro("HOST", self.context.build.host) self.define_macro("ARCH", self.context.build.arch) @@ -146,6 +147,7 @@ def init_default_exports(self): self.define_export("CFLAGS", " ".join(self.context.build.cflags)) self.define_export("CXXFLAGS", " ".join(self.context.build.cxxflags)) self.define_export("LDFLAGS", " ".join(self.context.build.ldflags)) + self.define_export("RUSTFLAGS", " ".join(self.context.build.rustflags)) self.define_export("FFLAGS", " ".join(self.context.build.cxxflags)) self.define_export("FCFLAGS", " ".join(self.context.build.cxxflags)) self.define_export("PATH", self.context.get_path()) diff --git a/ypkg2/ypkgcontext.py b/ypkg2/ypkgcontext.py index a67daa0..9f8579d 100644 --- a/ypkg2/ypkgcontext.py +++ b/ypkg2/ypkgcontext.py @@ -71,7 +71,8 @@ # Frame Pointer flags used for making profiling more useful at a slight hit to performance # See https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer -FRAME_POINTER_FLAGS = ["-fno-omit-frame-pointer", "-mno-omit-leaf-frame-pointer"] +FRAME_POINTER_FLAGS = ["-fno-omit-frame-pointer", "-mno-omit-leaf-frame-pointer", + "-Cforce-frame-pointers"] # The equivalent Rust flag # Clang can handle parameters to the args unlike GCC PGO_GEN_FLAGS_CLANG = "-fprofile-generate=\"{}/default-%m.profraw\"" @@ -97,6 +98,7 @@ class Flags: C = 0 CXX = 1 LD = 2 + RUST = 3 @staticmethod def get_desc(f): @@ -107,6 +109,8 @@ def get_desc(f): return "CXXFLAGS" elif f == Flags.LD: return "LDFLAGS" + elif f == Flags.RUST: + return "RUSTFLAGS" else: return "UNKNOWN_FLAG_SET_CHECK_IT" @@ -204,6 +208,7 @@ class BuildConfig: cflags = None cxxflags = None ldflags = None + rustflags = None cc = None cxx = None @@ -220,6 +225,8 @@ def get_flags(self, t): return self.cxxflags if t == Flags.LD: return self.ldflags + if t == Flags.RUST: + return self.rustflags return set([]) @@ -358,6 +365,7 @@ def init_config(self): self.build.cflags = list(conf.values.build.cflags.split(" ")) self.build.cxxflags = list(conf.values.build.cxxflags.split(" ")) self.build.ldflags = list(conf.values.build.ldflags.split(" ")) + self.build.rustflags = list(conf.values.build.rustflags.split(" ")) if conf.values.build.buildhelper: self.build.ccache = "ccache" in conf.values.build.buildhelper else: @@ -427,6 +435,10 @@ def init_optimize(self): self.build.cxxflags = Flags.optimize_flags(self.build.cxxflags, opt, self.spec.pkg_clang) + if opt == "no-frame-pointer": + self.build.rustflags = Flags.optimize_flags(self.build.rustflags, + opt, + self.spec.pkg_clang) if opt == "no-bind-now" or opt == "no-symbolic" \ or opt == "runpath" or opt == "icf-safe" \ or opt == "icf-all" or opt == "emit-relocs" :