From: Richard Levitte Date: Thu, 18 Feb 2016 17:43:56 +0000 (+0100) Subject: Rethink the uplink / applink story X-Git-Tag: OpenSSL_1_1_0-pre4~605 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=3a55c92bbad0b720c9a3d7a56fa3c351b65a89ee Rethink the uplink / applink story Adding uplink and applink to some builds was done by "magic", the configuration for "mingw" only had a macro definition, the Configure would react to its presence by adding the uplink source files to cpuid_asm_src, and crypto/build.info inherited dance to get it compiled, and Makefile.shared made sure applink.o would be appropriately linked in. That was a lot under the hood. To replace this, we create a few template configurations in Configurations/00-base-templates.conf, inherit one of them in the "mingw" configuration, the rest is just about refering to the $target{apps_aux_src} / $target{apps_obj} in the right places. Reviewed-by: Andy Polyakov --- diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf index cf5371b9ff..791634f352 100644 --- a/Configurations/00-base-templates.conf +++ b/Configurations/00-base-templates.conf @@ -12,7 +12,7 @@ thread_cflags => "", thread_defines => [], - apps_extra_src => "", + apps_aux_src => "", cpuid_asm_src => "mem_clr.c", bn_asm_src => "bn_asm.c", ec_asm_src => "", @@ -34,6 +34,7 @@ unistd => "", shared_target => "", shared_cflag => "", + shared_defines => [], shared_ldflag => "", shared_rcflag => "", shared_extension => "", @@ -41,6 +42,28 @@ build_file => "Makefile", }, + uplink_common => { + template => 1, + apps_aux_src => add(" ","../ms/applink.c"), + cpuid_asm_src => add(" ","../ms/uplink.c"), + shared_defines => add(undef, "OPENSSL_USE_APPLINK"), + }, + x86_uplink => { + inherit_from => [ "uplink_common" ], + template => 1, + cpuid_asm_src => add(" ","uplink-x86.s"), + }, + x86_64_uplink => { + inherit_from => [ "uplink_common" ], + template => 1, + cpuid_asm_src => add(" ","uplink-x86_64.s"), + }, + ia64_uplink => { + inherit_from => [ "uplink_common" ], + template => 1, + cpuid_asm_src => add(" ","uplink-ia64.s"), + }, + x86_asm => { template => 1, cpuid_asm_src => "x86cpuid.s", diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 03dc56bde1..4372d92614 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -1162,7 +1162,8 @@ #### MinGW "mingw" => { - inherit_from => [ asm("x86_asm") ], + inherit_from => [ asm("x86_asm"), + sub { $config{no_shared} ? () : "x86_uplink" } ], cc => "gcc", cflags => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall", debug_cflags => "-g -O0", @@ -1174,7 +1175,7 @@ perlasm_scheme => "coff", dso_scheme => "win32", shared_target => "cygwin-shared", - shared_cflag => "-D_WINDLL -DOPENSSL_USE_APPLINK", + shared_cflag => add(" ", "-D_WINDLL"), shared_ldflag => "-static-libgcc", shared_rcflag => "--target=pe-i386", shared_extension => ".dll", @@ -1200,7 +1201,7 @@ perlasm_scheme => "mingw64", dso_scheme => "win32", shared_target => "cygwin-shared", - shared_cflag => "-D_WINDLL", + shared_cflag => add(" ", "-D_WINDLL"), shared_ldflag => "-static-libgcc", shared_rcflag => "--target=pe-x86-64", shared_extension => ".dll", diff --git a/Configure b/Configure index 41fbf56eab..8fb2969a96 100755 --- a/Configure +++ b/Configure @@ -1013,10 +1013,6 @@ if ($target{ranlib} eq "") if (!$no_asm) { $target{cpuid_asm_src}=$table{BASE}->{cpuid_asm_src} if ($config{processor} eq "386"); - $target{cpuid_asm_src}.=" uplink.c uplink-x86.s" - if (grep { $_ eq "OPENSSL_USE_APPLINK"} @{$config{defines}} - or $config{cflags} =~ /(?:^|\s)-DOPENSSL_USE_APPLINK(?:\s|$)/); - $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m})); # bn-586 is the only one implementing bn_*_part_words @@ -1542,9 +1538,9 @@ EOF # For the schemes that need it, we provide the old *_obj configs # from the *_asm_obj ones -foreach (grep /_asm_src$/, keys %target) { +foreach (grep /_(asm|aux)_src$/, keys %target) { my $src = $_; - (my $obj = $_) =~ s/_asm_src$/_obj/; + (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/; ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g; } diff --git a/Makefile.in b/Makefile.in index 79a1ea95eb..9912d8868a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -120,6 +120,7 @@ ASFLAG=$(CFLAG) PROCESSOR= {- $config{processor} -} # CPUID module collects small commonly used assembler snippets +APPS_OBJ={- $target{apps_obj} -} CPUID_OBJ= {- $target{cpuid_obj} -} BN_ASM= {- $target{bn_obj} -} EC_ASM= {- $target{ec_obj} -} @@ -260,6 +261,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\ SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \ LDFLAG='$(LDFLAG)' \ PLIB_LDFLAG='$(PLIB_LDFLAG)' EX_LIBS='$(EX_LIBS)' \ + APPS_OBJ='$(APPS_OBJ)' \ CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)' \ EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)' \ AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)' \ diff --git a/Makefile.shared b/Makefile.shared index 159e9ecc0e..90290d1883 100644 --- a/Makefile.shared +++ b/Makefile.shared @@ -319,10 +319,6 @@ link_a.cygwin: $(LINK_SO_A) || exit 1; \ rm $$extras link_app.cygwin: - @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \ - LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \ - export LIBDEPS; \ - fi; \ $(LINK_APP) link_o.alpha-osf1: diff --git a/apps/Makefile.in b/apps/Makefile.in index d49afece36..956d84b4d7 100644 --- a/apps/Makefile.in +++ b/apps/Makefile.in @@ -15,6 +15,8 @@ PLIB_LDFLAG= EX_LIBS= EXE_EXT= +APPS_OBJ= + SHLIB_TARGET= CFLAGS= $(INCLUDES) $(CFLAG) @@ -52,7 +54,7 @@ SRC = \ s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c \ srp.c ts.c verify.c version.c x509.c rehash.c -EXE_OBJ = openssl.o $(OBJ) $(EXTRA_OBJ) $(RAND_OBJ) +EXE_OBJ = openssl.o $(OBJ) $(EXTRA_OBJ) $(RAND_OBJ) $(APPS_OBJ) EXE_SRC = openssl.c $(SRC) $(EXTRA_SRC) $(RAND_SRC) HEADER= apps.h progs.h s_apps.h \ diff --git a/apps/build.info b/apps/build.info index a7dcee6e1a..d581aad4bf 100644 --- a/apps/build.info +++ b/apps/build.info @@ -10,7 +10,7 @@ SOURCE[openssl]=\ srp.c ts.c verify.c version.c x509.c rehash.c \ apps.c opt.c s_cb.c s_socket.c \ app_rand.c \ - {- $target{apps_extra_src} -} + {- $target{apps_aux_src} -} INCLUDE[openssl]={- rel2abs(catdir($builddir,"../include")) -} .. ../include DEPEND[openssl]=../libssl diff --git a/crypto/build.info b/crypto/build.info index 507e998fc5..b360ff876e 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -21,12 +21,6 @@ crypto/buildinf.h : Makefile ##### APPLINK, UPLINK and CPUID assembler implementations -{- $builddir -}/applink.o: $(SRCDIR)/ms/applink.c - $(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/ms/applink.c - -{- $builddir -}/uplink.o: $(SRCDIR)/ms/uplink.c {- $builddir -}/applink.o - $(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/ms/uplink.c - {- $builddir -}/uplink-x86.s: $(SRCDIR)/ms/uplink-x86.pl CC="$(CC)" $(PERL) $(SRCDIR)/ms/uplink-x86.pl $(PERLASM_SCHEME) > $@