Commit c86ddbe6 authored by Richard Levitte's avatar Richard Levitte
Browse files

Enhance and clear the support of linker flags



Some time ago, we had a ex_libs configuration setting that could be
divided into lflags and ex_libs.  These got divided in two settings,
lflags and ex_libs, and the former was interpreted to be general
linking flags.

Unfortunately, that conclusion wasn't entirely accurate.  Most of
those linking were meant to end up in a very precise position on the
linking command line, just before the spec of libraries the linking
depends on.

Back to the drawing board, we're diving things further, now having
lflags, which are linking flags that aren't depending on command line
position, plib_lflags, which are linking flags that should show up just
before the spec of libraries to depend on, and finally ex_libs, which
is the spec of extra libraries to depend on.

Also, documentation is changed in Configurations/README.  This was
previously forgotten.

Reviewed-by: default avatarKurt Roeckx <kurt@openssl.org>
parent b438f0ed
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1345,7 +1345,7 @@
        release_cflags   => "-O3",
        thread_cflag     => "-D_REENTRANT",
        sys_id           => "MACOSX",
        lflags           => "-Wl,-search_paths_first",
        plib_lflags      => "-Wl,-search_paths_first",
        bn_ops           => "BN_LLONG RC4_CHAR",
        perlasm_scheme   => "osx32",
        dso_scheme       => "dlfcn",
@@ -1498,7 +1498,7 @@
        cc               => "$ENV{'CC'}",
        cflags           => "\$(CFLAGS)",
        thread_cflag     => "-D_REENTRANT",
        lflags           => "\$(LDFLAGS)",
        plib_lflags      => "\$(LDFLAGS)",
        ex_libs          => "\$(LDLIBS)",
        bn_ops           => "BN_LLONG",
        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
@@ -1512,7 +1512,7 @@
        cc               => "$ENV{'CC'}",
        cflags           => "\$(CFLAGS)",
        thread_cflag     => "-D_REENTRANT",
        lflags           => "\$(LDFLAGS)",
        plib_lflags      => "\$(LDFLAGS)",
        ex_libs          => "\$(LDLIBS)",
        bn_ops           => "SIXTY_FOUR_BIT_LONG",
        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@
        cflags           => "$gcc_devteam_warn -Wno-language-extension-token -Wno-extended-offsetof -arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall",
        thread_cflag     => "-D_REENTRANT",
        sys_id           => "MACOSX",
        lflags           => "-Wl,-search_paths_first",
        plib_lflags      => "-Wl,-search_paths_first",
        bn_ops           => "SIXTY_FOUR_BIT_LONG",
        perlasm_scheme   => "macosx",
        dso_scheme       => "dlfcn",
+34 −12
Original line number Diff line number Diff line
@@ -39,25 +39,22 @@ In each table entry, the following keys are significant:
                           compiling for shared libraries, typically
                           something like "-fPIC".

        ld              => the linker command, usually not defined
        (linking is a complex thing, see [3] below)
        ld              => Linker command, usually not defined
                           (meaning the compiler command is used
                           instead).
                           (NOTE: this is here for future use, it's
                           not implemented yet)
        lflags          => the flags that are used at all times when
                           linking.  These can have a % sign in them
                           showing where the OpenSSL libraries should
                           appear, otherwise these flags will come
                           last.  So in a typical links situation,
                           this is a quick table of results:

                           "-foo%-bar"  > -foo -lssl -lcrypto -bar
                           "-foo%"      > -foo -lssl -lcrypto
                           "-foo"       > -lssl -lcrypto -foo
        lflags          => Flags that are used when linking apps.
        shared_ldflag   => Flags that are used when linking shared
                           or dynamic libraries.
        plib_lflags     => Extra linking flags to appear just before
                           the libraries on the command line.
        ex_libs         => Extra libraries that are needed when
                           linking.

        debug_lflags    => Like debug_cflags, but used when linking.
        release_lflags  => Like release_cflags, but used when linking.
        shared_lflags   => Like shared_cflags, but used when linking.

        ar              => The library archive command, the default is
                           "ar".
@@ -253,6 +250,31 @@ In each table entry, the following keys are significant:
    be "(unknown)", in which case the user MUST give some compilation
    flags to Configure.

[3] OpenSSL has three types of things to link from object files or
    static libraries:

    - shared libraries; that would be libcrypto and libssl.
    - shared objects (sometimes called dynamic libraries);  that would
      be the engines.
    - applications; those are apps/openssl and all the test apps.

    Very roughly speaking, linking is done like this (words in braces
    represent the configuration settings documented at the beginning
    of this file):

    shared libraries:
        {ld} $(CFLAGS) {shared_ldflag} -shared -o libfoo.so \
            -Wl,--whole-archive libfoo.a -Wl,--no-whole-archive \
            {plib_lflags} -lcrypto {ex_libs}

    shared objects:
        {ld} $(CFLAGS) {shared_ldflag} -shared -o libeng.so \
            blah1.o blah2.o {plib_lflags} -lcrypto {ex_libs}

    applications:
        {ld} $(CFLAGS) {lflags} -o app \
            app1.o utils.o {plib_lflags} -lssl -lcrypto {ex_libs}


Historically, the target configurations came in form of a string with
values separated by colons.  This use is deprecated.  The string form
+10 −2
Original line number Diff line number Diff line
@@ -820,7 +820,8 @@ $config{openssldir} = catdir($config{prefix}, $config{openssldir})
# Allow environment CC to override compiler...
$target{cc} = $ENV{CC} || $target{cc};

# For cflags, lflags and ex_libs, add the debug_ or release_ attributes
# For cflags, lflags, plib_lflags and ex_libs, add the debug_ or release_
# attributes.
# Do it in such a way that no spurious space is appended (hence the grep).
$config{cflags} = join(" ",
		       grep { $_ ne "" } ($target{cflags},
@@ -828,6 +829,9 @@ $config{cflags} = join(" ",
$config{lflags} = join(" ",
		       grep { $_ ne "" } ($target{lflags},
					  $target{$build_prefix."lflags"}));
$config{plib_lflags} = join(" ",
			    grep { $_  ne "" } ($target{plib_lflags},
					        $target{$build_prefix."plib_lflags"}));
$config{ex_libs} = join(" ",
			grep { $_  ne "" } ($target{ex_libs},
					    $target{$build_prefix."ex_libs"}));
@@ -1653,7 +1657,8 @@ EOF
print "IsMK1MF       =", ($target{build_scheme}->[0] eq "mk1mf" ? "yes" : "no"), "\n";
print "CC            =$target{cc}\n";
print "CFLAG         =$config{cflags}\n";
print "LFLAGS        =$config{lflags}\n";
print "LFLAG         =$config{lflags}\n";
print "PLIB_LFLAG    =$config{plib_lflags}\n";
print "EX_LIBS       =$config{ex_libs}\n";
print "CPUID_OBJ     =$target{cpuid_obj}\n";
print "BN_ASM        =$target{bn_obj}\n";
@@ -2116,10 +2121,13 @@ sub print_table_entry
	"unistd",
	"ld",
	"lflags",
	"plib_lflags",
	"ex_libs",
	"debug_lflags",
	"debug_plib_lflags",
	"debug_ex_libs",
	"release_lflags",
	"release_plib_lflags",
	"release_ex_libs",
	"bn_ops",
	"cpuid_obj",
+6 −4
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ CROSS_COMPILE= {- $config{cross_compile_prefix} -}
CC= $(CROSS_COMPILE){- $target{cc} -}
CFLAG= {- $config{cflags} -}
DEPFLAG= {- $config{depflags} -}
LDFLAGS= {- $config{lflags} -}
LDFLAG= {- $config{lflags} -}
PLIB_LDFLAG= {- $config{plib_lflags} -}
EX_LIBS= {- $config{ex_libs} -}
EXE_EXT= {- $target{exe_extension} -}
ARFLAGS= {- $target{arflags} -}
@@ -159,7 +160,7 @@ LIBS= libcrypto.a libssl.a
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
SHARED_SSL=libssl$(SHLIB_EXT)
SHARED_LIBS={- '$(SHARED_CRYPTO) $(SHARED_SSL)' if (!$config{no_shared}) -}
SHARED_LDFLAGS={- $target{shared_ldflag} -}
SHARED_LDFLAG={- $target{shared_ldflag} -}

GENERAL=        Makefile
BASENAME=       openssl
@@ -209,11 +210,12 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
		INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)'	\
		LIBDIR='$(LIBDIR)'				\
		DEPFLAG='$(DEPFLAG)'                    	\
		SHARED_LDFLAGS='$(SHARED_LDFLAGS)'		\
		SHARED_LDFLAG='$(SHARED_LDFLAG)'		\
		ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)'	\
		EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)'	\
		SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)'	\
		LDFLAGS='$(LDFLAGS)' EX_LIBS='$(EX_LIBS)'	\
		LDFLAG='$(LDFLAG)'				\
		PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)'	\
		CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)'	\
		EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)'		\
		AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)'	\
Loading