Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

rust: Add RUSTFLAGS #82

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ypkg2/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand Down
14 changes: 13 additions & 1 deletion ypkg2/ypkgcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
Expand All @@ -97,6 +98,7 @@ class Flags:
C = 0
CXX = 1
LD = 2
RUST = 3

@staticmethod
def get_desc(f):
Expand All @@ -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"

Expand Down Expand Up @@ -204,6 +208,7 @@ class BuildConfig:
cflags = None
cxxflags = None
ldflags = None
rustflags = None

cc = None
cxx = None
Expand All @@ -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([])


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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" :
Expand Down