Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
Add --with-nonshared-cflags option to configure
Browse files Browse the repository at this point in the history
  • Loading branch information
fweimer-rh committed Aug 17, 2018
1 parent 93a2584 commit 6413fcd
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
2018-08-16 Florian Weimer <fweimer@redhat.com>

* configure.ac: Add --with-nonshared-cflags option.
* config.make.in (extra-nonshared-cflags): Set variable.
* Makeconfig (CFLAGS-.oS): Use it.
* manual/install.texi (Configuring and compiling): Document
--with-nonshared-cflags.
* configure: Regenerate.
* INSTALL: Likewise.

2018-08-16 Florian Weimer <fweimer@redhat.com>

* Makeconfig (ASFLAGS): Always append required assembler flags.
Expand Down
16 changes: 16 additions & 0 deletions INSTALL
Expand Up @@ -90,6 +90,22 @@ if 'CFLAGS' is specified it must enable optimization. For example:
library will still be usable, but functionality may be lost--for
example, you can't build a shared libc with old binutils.

'--with-nonshared-cflags=CFLAGS'
Use additional compiler flags CFLAGS to build the parts of the
library which are always statically linked into applications and
libraries even with shared linking (that is, the object files
contained in 'lib*_nonshared.a' libraries). The build process will
automatically use the appropriate flags, but this option can be
used to set additional flags required for building applications and
libraries, to match local policy. For example, if such a policy
requires that all code linked into applications must be built with
source fortification,
'--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2' will make sure
that the objects in 'libc_nonshared.a' are compiled with this flag
(although this will not affect the generated code in this
particular case and potentially change debugging information and
metadata only).

'--disable-shared'
Don't build shared libraries even if it is possible. Not all
systems support shared libraries; you need ELF support and
Expand Down
2 changes: 1 addition & 1 deletion Makeconfig
Expand Up @@ -1038,7 +1038,7 @@ object-suffixes-for-libc += .oS
# Must build the routines as PIC, though, because they can end up in (users')
# shared objects. We don't want to use CFLAGS-os because users may, for
# example, make that processor-specific.
CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
libtype.oS = lib%_nonshared.a
endif
Expand Down
1 change: 1 addition & 0 deletions config.make.in
Expand Up @@ -110,6 +110,7 @@ BUILD_CC = @BUILD_CC@
CFLAGS = @CFLAGS@
CPPFLAGS-config = @CPPFLAGS@
CPPUNDEFS = @CPPUNDEFS@
extra-nonshared-cflags = @extra_nonshared_cflags@
ASFLAGS-config = @ASFLAGS_config@
AR = @AR@
NM = @NM@
Expand Down
14 changes: 14 additions & 0 deletions configure
Expand Up @@ -684,6 +684,7 @@ force_install
bindnow
hardcoded_path_in_tests
enable_timezone_tools
extra_nonshared_cflags
use_default_link
sysheaders
ac_ct_CXX
Expand Down Expand Up @@ -762,6 +763,7 @@ with_binutils
with_selinux
with_headers
with_default_link
with_nonshared_cflags
enable_sanity_checks
enable_shared
enable_profile
Expand Down Expand Up @@ -1482,6 +1484,8 @@ Optional Packages:
--with-headers=PATH location of system headers to use (for example
/usr/src/linux/include) [default=compiler default]
--with-default-link do not use explicit linker scripts
--with-nonshared-cflags=CFLAGS
build nonshared libraries with additional CFLAGS
--with-cpu=CPU select code for CPU variant
Some influential environment variables:
Expand Down Expand Up @@ -3339,6 +3343,16 @@ else
fi



# Check whether --with-nonshared-cflags was given.
if test "${with_nonshared_cflags+set}" = set; then :
withval=$with_nonshared_cflags; extra_nonshared_cflags=$withval
else
extra_nonshared_cflags=
fi



# Check whether --enable-sanity-checks was given.
if test "${enable_sanity_checks+set}" = set; then :
enableval=$enable_sanity_checks; enable_sanity=$enableval
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Expand Up @@ -154,6 +154,14 @@ AC_ARG_WITH([default-link],
[use_default_link=$withval],
[use_default_link=default])

dnl Additional build flags injection.
AC_ARG_WITH([nonshared-cflags],
AC_HELP_STRING([--with-nonshared-cflags=CFLAGS],
[build nonshared libraries with additional CFLAGS]),
[extra_nonshared_cflags=$withval],
[extra_nonshared_cflags=])
AC_SUBST(extra_nonshared_cflags)

AC_ARG_ENABLE([sanity-checks],
AC_HELP_STRING([--disable-sanity-checks],
[really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
Expand Down
14 changes: 14 additions & 0 deletions manual/install.texi
Expand Up @@ -117,6 +117,20 @@ problem and suppress these constructs, so that the library will still be
usable, but functionality may be lost---for example, you can't build a
shared libc with old binutils.

@item --with-nonshared-cflags=@var{cflags}
Use additional compiler flags @var{cflags} to build the parts of the
library which are always statically linked into applications and
libraries even with shared linking (that is, the object files contained
in @file{lib*_nonshared.a} libraries). The build process will
automatically use the appropriate flags, but this option can be used to
set additional flags required for building applications and libraries,
to match local policy. For example, if such a policy requires that all
code linked into applications must be built with source fortification,
@samp{--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2} will make sure
that the objects in @file{libc_nonshared.a} are compiled with this flag
(although this will not affect the generated code in this particular
case and potentially change debugging information and metadata only).

@c disable static doesn't work currently
@c @item --disable-static
@c Don't build static libraries. Static libraries aren't that useful these
Expand Down

0 comments on commit 6413fcd

Please sign in to comment.