From 731202317a6ae144e6abe3ceb3fc477604a4c778 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Tue, 30 Jan 2018 11:34:24 -0500 Subject: [PATCH] Ticket 49400 - Make CLANG configurable Description: Make clang configurable and off by default https://pagure.io/389-ds-base/issue/49400 Reviewed by: ? --- Makefile.am | 11 ++++++++++- configure.ac | 12 ++++++++++++ rpm.mk | 2 ++ rpm/389-ds-base.spec.in | 10 ++++++---- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 34efb0734..9fae072a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,6 +51,14 @@ else PERL_ON = 0 endif +if CLANG_ENABLE +CLANG_ON = 1 +CLANG_LDFLAGS = -latomic +else +CLANG_ON = 0 +CLANG_LDFLAGS = +endif + # We can't add the lfds includes all the time as they have a "bomb" in them that # prevents compilation on unsupported hardware arches. if ATOMIC_QUEUE_OPERATIONS @@ -157,7 +165,7 @@ AM_LDFLAGS = -lpthread else #AM_LDFLAGS = -Wl,-z,defs # Provide the tcmalloc links if needed -AM_LDFLAGS = $(RUST_LDFLAGS) $(ASAN_DEFINES) $(PROFILING_LINKS) $(TCMALLOC_LINK) -latomic +AM_LDFLAGS = $(RUST_LDFLAGS) $(ASAN_DEFINES) $(PROFILING_LINKS) $(TCMALLOC_LINK) $(CLANG_LDFLAGS) endif #end hpux # https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info @@ -2365,6 +2373,7 @@ rpmbrprep: dist-bzip2 rpmroot -e "s/__VERSION_PREREL__/$(VERSION_PREREL)/" \ -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" \ -e "s/__RUST_ON__/$(RUST_ON)/" \ + -e "s/__CLANG_ON__/$(CLANG_ON)/" \ -e "s/__PERL_ON__/$(PERL_ON)/" \ -e "s/__ASAN_ON__/$(ASAN_ON)/" < $(abs_builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec diff --git a/configure.ac b/configure.ac index 981f8e21f..82633a0d5 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,18 @@ AC_SUBST([asan_defs]) AC_SUBST([asan_rust_defs]) AM_CONDITIONAL(enable_asan,test "$enable_asan" = "yes") +# Enable CLANG +AC_MSG_CHECKING(for --enable-clang) +AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-clang], [Enable clang (default: no)]), +[ + AC_MSG_RESULT(yes) +], +[ + AC_MSG_RESULT(no) +]) +AM_CONDITIONAL(CLANG_ENABLE,test "$enable_clang" = "yes") + +# Enable Perl if test -z "$enable_perl" ; then enable_perl=yes fi diff --git a/rpm.mk b/rpm.mk index c15ff6c73..70ead75ce 100644 --- a/rpm.mk +++ b/rpm.mk @@ -12,6 +12,7 @@ NUNC_STANS_ON = 1 ASAN_ON = 0 RUST_ON = 0 PERL_ON = 1 +CLANG_ON = 0 clean: rm -rf dist @@ -40,6 +41,7 @@ rpmroot: -e s/__RUST_ON__/$(RUST_ON)/ \ -e s/__ASAN_ON__/$(ASAN_ON)/ \ -e s/__PERL_ON__/$(PERL_ON)/ \ + -e s/__CLANG_ON__/$(CLANG_ON)/ \ rpm/$(PACKAGE).spec.in > $(RPMBUILD)/SPECS/$(PACKAGE).spec rpmdistdir: diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index d99d2de75..7a93ee35b 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -34,7 +34,7 @@ %endif # Use Clang instead of GCC -%global use_clang 0 +%global use_clang __CLANG_ON__ # fedora 15 and later uses tmpfiles.d # otherwise, comment this out @@ -71,8 +71,8 @@ BuildRequires: cyrus-sasl-devel BuildRequires: icu BuildRequires: libicu-devel BuildRequires: pcre-devel -BuildRequires: libatomic %if %{use_clang} +BuildRequires: libatomic BuildRequires: clang %else BuildRequires: gcc-c++ @@ -268,9 +268,11 @@ The lib389 CI tests that can be run against the Directory Server. cp %{SOURCE2} README.devel %build + %if %{use_clang} export CC=clang export CXX=clang++ +CLANG_FLAGS="--enable-clang" %endif %{?with_tmpfiles_d: TMPFILES_FLAG="--with-tmpfiles-d=%{with_tmpfiles_d}"} @@ -301,8 +303,8 @@ autoreconf -fiv --with-systemdsystemunitdir=%{_unitdir} \ --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \ --with-systemdgroupname=%{groupname} \ - $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS $RUST_FLAGS $PERL_FLAGS \ - --enable-cmocka 'LDFLAGS=-Wl,-z,defs' + $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS $RUST_FLAGS $PERL_FLAGS $CLANG_FLAGS \ + --enable-cmocka %if 0%{?rhel} >= 8 || 0%{?fedora} make setup.py -- 2.13.6