Skip to content

Commit

Permalink
build-sys: Switch to clang by default
Browse files Browse the repository at this point in the history
Eventually we want to do cross-language LTO:
https://developers.redhat.com/blog/2020/03/18/cross-language-link-time-optimization-using-red-hat-developer-tools/

But in the immediate term, using clang/lld instead of ld.bfd (or ld.gold)
works around a linker bug: #2518 (comment)
  • Loading branch information
cgwalters committed Feb 1, 2021
1 parent bccde5f commit 5f82919
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 0 additions & 4 deletions Makefile-lib.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ librpmostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libp
librpmostree_1_la_LDFLAGS = $(AM_LDFLAGS) -version-number 1:0:0 -Bsymbolic-functions
librpmostree_1_la_LIBADD = $(PKGDEP_LIBRPMOSTREE_LIBS) libglnx.la

# XXX: work around clang being passed -fstack-clash-protection which it doesn't understand
# https://github.com/projectatomic/rpm-ostree/pull/1787#issuecomment-473971585
INTROSPECTION_SCANNER_ENV = CC=gcc

if BUILDOPT_INTROSPECTION
RpmOstree-1.0.gir: librpmostree-1.la Makefile
RpmOstree_1_0_gir_EXPORT_PACKAGES = rpm-ostree-1
Expand Down
4 changes: 3 additions & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ ${dn}/installdeps.sh
rustc --version

export LSAN_OPTIONS=verbosity=1:log_threads=1
# And now the build
# And now the build; we use clang by default. For more information
# see the spec file.
export CC=clang CXX=clang++ LD=/usr/bin/ld.lld RUSTFLAGS="-C link-arg=-fuse-ld=lld"
build --enable-installed-tests --enable-gtk-doc ${CONFIGOPTS:-}
23 changes: 16 additions & 7 deletions packaging/rpm-ostree.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ Source0: https://github.com/coreos/rpm-ostree/releases/download/v%{version}/rpm-

ExclusiveArch: %{rust_arches}

# rpm-ostree is a hybrid C/C++/Rust program; currently using autotools:
# We always run autogen.sh
BuildRequires: autoconf automake libtool git
BuildRequires: make
# Use LLVM by default for multiple reasons.
# First, eventually we want to do cross-language LTO:
# https://developers.redhat.com/blog/2020/03/18/cross-language-link-time-optimization-using-red-hat-developer-tools/
# But in the immediate term, using clang/lld instead of ld.bfd (or ld.gold)
# works around a linker bug: https://github.com/coreos/rpm-ostree/pull/2518#issuecomment-770918530
# also xref https://github.com/rust-lang/rust/issues/53945#issuecomment-425620542
BuildRequires: clang lld

# Rust dependencies.
%if 0%{?rhel} && !0%{?eln}
BuildRequires: rust-toolset
%else
Expand All @@ -37,8 +49,6 @@ BuildRequires: rust

# For the autofiles bits below
BuildRequires: /usr/bin/python3
# We always run autogen.sh
BuildRequires: autoconf automake libtool git
# For docs
BuildRequires: chrpath
BuildRequires: gtk-doc
Expand Down Expand Up @@ -66,10 +76,6 @@ BuildRequires: pkgconfig(expat)
BuildRequires: pkgconfig(check)
BuildRequires: pkgconfig(libsolv)

# We need g++ for libdnf
BuildRequires: gcc-c++


# more libdnf build deps (see libdnf's spec for versions)
%global swig_version 3.0.12
%global libmodulemd_version 2.5.0
Expand Down Expand Up @@ -130,7 +136,10 @@ env NOCONFIGURE=1 ./autogen.sh
# Since we're hybrid C++/Rust we need to propagate this manually;
# the %%configure macro today assumes (reasonably) that one is building
# C/C++ and sets C{,XX}FLAGS
export RUSTFLAGS="%{build_rustflags}"
# FIXME uncomment and debug this
# export RUSTFLAGS="%{build_rustflags}"
# See comment in the BuildRequires for why we use clang
export CC=clang CXX=clang++ LD=/usr/bin/ld.lld RUSTFLAGS="-C link-arg=-fuse-ld=lld"
%configure --disable-silent-rules --enable-gtk-doc %{?sqlite_rpmdb_default}
%make_build

Expand Down

0 comments on commit 5f82919

Please sign in to comment.