public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* A new static binary patch
@ 1999-08-27 13:51 H.J. Lu
  1999-08-27 19:06 ` Geoff Keating
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 1999-08-27 13:51 UTC (permalink / raw)
  To: GNU C Library

Here is a new static binary patch. I also put the new c_stubs addon at

ftp://ftp.valinux.com/pub/support/hjl/glibc/glibc-c_stubs-2.1.2.tar.gz


-- 
H.J. Lu (hjl@gnu.org)
--
Fri Aug 27 13:46:16 1999  H.J. Lu  <hjl@gnu.org>

	* Makeconfig (built-program-cmd): Don't use the dynamic linker
	to run a binary if it is in $(tests-static).

Wed Aug 25 09:59:15 1999  H.J. Lu  <hjl@gnu.org>

	* Rules (binaries-static): Add $(tests-static).

Index: Makeconfig
===================================================================
RCS file: /work/cvs/gnu/glibc/Makeconfig,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makeconfig
--- Makeconfig	1999/08/08 17:01:06	1.1.1.1
+++ Makeconfig	1999/08/27 20:43:37
@@ -478,12 +478,22 @@ sysdep-library-path = \
 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
 				       $(filter -Wl$(comma)-rpath-link=%,\
 						$(sysdep-LDFLAGS)))))
-define built-program-cmd
+define run-built-program-cmd
 $(elf-objpfx)$(rtld-installed-name) \
 	--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
 	$(built-program-file)
 endef
-endif
+ifeq ("",$(tests-static))
+built-program-cmd = $(run-built-program-cmd)
+else
+define built-program-cmd 
+	$(shell if [ x$(findstring $(notdir $(built-program-file)), \
+			$(tests-static)) = x ]; \
+		then echo $(run-built-program-cmd); \
+		else echo $(built-program-file); fi)
+endef
+endif	# tests-static
+endif	# build-shared
 
 ifndef LD
 LD := ld -X
Index: Rules
===================================================================
RCS file: /work/cvs/gnu/glibc/Rules,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 Rules
--- Rules	1999/08/23 16:16:40	1.1.1.2
+++ Rules	1999/08/25 17:12:22
@@ -93,7 +93,7 @@ endif
 
 ifeq ($(build-programs),yes)
 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
-binaries-static = $(others-static)
+binaries-static = $(others-static) $(tests-static)
 else
 binaries-all = $(tests) $(test-srcs)
 binaries-static =

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A new static binary patch
  1999-08-27 13:51 A new static binary patch H.J. Lu
@ 1999-08-27 19:06 ` Geoff Keating
  1999-08-27 19:18   ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Geoff Keating @ 1999-08-27 19:06 UTC (permalink / raw)
  To: hjl; +Cc: libc-hacker

> Date: Fri, 27 Aug 1999 13:51:30 -0700 (PDT)
> From: hjl@varesearch.com (H.J. Lu)

> +ifeq ("",$(tests-static))
> +built-program-cmd = $(run-built-program-cmd)
> +else
> +define built-program-cmd 
> +	$(shell if [ x$(findstring $(notdir $(built-program-file)), \
> +			$(tests-static)) = x ]; \
> +		then echo $(run-built-program-cmd); \
> +		else echo $(built-program-file); fi)
> +endef
> +endif	# tests-static

No!

Just create a _new_ rule, which _only_ knows how to run static
programs.  Don't try to make the existing rule, which is for running
non-static programs, do both jobs.

Would you try to create a rule which knew how to build a .a library
and build a .so library?

I find it particularly ugly that this is going to cause an additional
shell invocation for every program executed.

-- 
Geoffrey Keating <geoffk@cygnus.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A new static binary patch
  1999-08-27 19:06 ` Geoff Keating
@ 1999-08-27 19:18   ` H.J. Lu
  1999-08-27 19:50     ` Geoff Keating
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 1999-08-27 19:18 UTC (permalink / raw)
  To: Geoff Keating; +Cc: libc-hacker

> 
> > Date: Fri, 27 Aug 1999 13:51:30 -0700 (PDT)
> > From: hjl@varesearch.com (H.J. Lu)
> 
> > +ifeq ("",$(tests-static))
> > +built-program-cmd = $(run-built-program-cmd)
> > +else
> > +define built-program-cmd 
> > +	$(shell if [ x$(findstring $(notdir $(built-program-file)), \
> > +			$(tests-static)) = x ]; \
> > +		then echo $(run-built-program-cmd); \
> > +		else echo $(built-program-file); fi)
> > +endef
> > +endif	# tests-static
> 
> No!
> 
> Just create a _new_ rule, which _only_ knows how to run static
> programs.  Don't try to make the existing rule, which is for running
> non-static programs, do both jobs.

I couldn't find a better way. Wrong, the existing rule uses
$(built-program-cmd) which can handle static or dynamic, but not
both.

> 
> Would you try to create a rule which knew how to build a .a library
> and build a .so library?
> 
> I find it particularly ugly that this is going to cause an additional
> shell invocation for every program executed.
> 

I take you will define "tests-static" in every Makefile. Otherwise,
what you said won't happen.


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A new static binary patch
  1999-08-27 19:18   ` H.J. Lu
@ 1999-08-27 19:50     ` Geoff Keating
  0 siblings, 0 replies; 5+ messages in thread
From: Geoff Keating @ 1999-08-27 19:50 UTC (permalink / raw)
  To: hjl; +Cc: libc-hacker

> Date: Fri, 27 Aug 1999 19:17:32 -0700 (PDT)
> Cc: libc-hacker@sourceware.cygnus.com
> From: hjl@lucon.org (H.J. Lu)

> > Just create a _new_ rule, which _only_ knows how to run static
> > programs.  Don't try to make the existing rule, which is for running
> > non-static programs, do both jobs.
> 
> I couldn't find a better way.

Try the following.  It needs a ChangeLog entry.  It took me 6 minutes,
and I haven't tested it.  I think it automatically builds the
executables, you might want to change that.  The only slightly ugly
thing about it is that you get '.sout' files, the better thing to do
would be to write 

$(tests-static:%=$(objpfx)%.out) : $(objpfx)%.out: %.args $(objpfx)% %.input

in the rules, and a similar thing for the non-static rules.

-- 
Geoffrey Keating <geoffk@cygnus.com>

===File ~/z=================================================
--- BUILD/glibc-2.1.2pre3/Rules~	Mon Jan 18 20:26:53 1999
+++ BUILD/glibc-2.1.2pre3/Rules	Sat Aug 28 12:46:54 1999
@@ -86,17 +86,17 @@
 others: $(addprefix $(objpfx),$(extra-objs))
 endif
 ifeq ($(cross-compiling),yes)
-tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
+tests: $(addprefix $(objpfx),$(tests) $(test-srcs) $(tests-static))
 else
-tests: $(tests:%=$(objpfx)%.out)
+tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
 endif
 
 ifeq ($(build-programs),yes)
 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
-binaries-static = $(others-static)
+binaries-static = $(others-static) $(tests-static)
 else
 binaries-all = $(tests) $(test-srcs)
-binaries-static =
+binaries-static = $(tests-static)
 endif
 
 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
@@ -127,6 +127,16 @@
 $(objpfx)%.out: /dev/null $(objpfx)%	# Make it 2nd arg for canned sequence.
 	$($*-ENV) $(built-program-cmd) > $@
 endif	# tests
+ifneq "$(strip $(tests-static))" ""
+$(objpfx)%.sout: %.args $(objpfx)% %.input
+	$($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
+$(objpfx)%.sout: %.args $(objpfx)%
+	$($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
+$(objpfx)%.sout: %.input $(objpfx)%
+	$($*-ENV) $(built-program-file) < $(word 1,$^) > $@
+$(objpfx)%.sout: /dev/null $(objpfx)%	# Make it 2nd arg for canned sequence.
+	$($*-ENV) $(built-program-file) > $@
+endif	# tests-static
 \f
 .PHONY: distclean realclean subdir_distclean subdir_realclean \
 	subdir_clean subdir_mostlyclean subdir_testclean
============================================================

^ permalink raw reply	[flat|nested] 5+ messages in thread

* A new static binary patch
@ 1999-08-23 21:01 H.J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 1999-08-23 21:01 UTC (permalink / raw)
  To: GNU C Library

Please discard my previous patch. I will update my c_stubs addon soon.

-- 
H.J. Lu (hjl@gnu.org)
---
Mon Aug 23 17:22:53 1999  H.J. Lu  <hjl@gnu.org>

	* Makeconfig (FILE): Define.

	* Rules (%.out): Run $(FILE) on the binary before running it
	and don't use the dynamic linker if it is not dynamically
	linked.

Index: Makeconfig
===================================================================
RCS file: /work/cvs/gnu/glibc/Makeconfig,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makeconfig
--- Makeconfig	1999/08/08 17:01:06	1.1.1.1
+++ Makeconfig	1999/08/23 23:20:28
@@ -493,6 +493,10 @@ ifndef	RANLIB
 RANLIB = ranlib
 endif
 
+ifndef FILE
+FILE := file
+endif
+
 # Extra flags to pass to GCC.
 +gccwarn := -Wall -Wwrite-strings -Winline -Wstrict-prototypes
 
Index: Rules
===================================================================
RCS file: /work/cvs/gnu/glibc/Rules,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 Rules
--- Rules	1999/08/23 16:16:40	1.1.1.2
+++ Rules	1999/08/23 23:26:41
@@ -119,13 +119,33 @@ ifneq "$(strip $(tests) $(test-srcs))" "
 # These are the implicit rules for making test outputs
 # from the test programs and whatever input files are present.
 $(objpfx)%.out: %.args $(objpfx)% %.input
-	$($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
+	$(FILE) $(built-program-file) | grep dynamically > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@; \
+	fi
 $(objpfx)%.out: %.args $(objpfx)%
-	$($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
+	$(FILE) $(built-program-file) | grep dynamically > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@; \
+	fi
 $(objpfx)%.out: %.input $(objpfx)%
-	$($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
+	$(FILE) $(built-program-file) | grep dynamically > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) < $(word 1,$^) > $@; \
+	fi
 $(objpfx)%.out: /dev/null $(objpfx)%	# Make it 2nd arg for canned sequence.
-	$($*-ENV) $(built-program-cmd) > $@
+	$(FILE) $(built-program-file) | grep dynamically > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) > $@; \
+	fi
 endif	# tests
 \f
 .PHONY: distclean realclean subdir_distclean subdir_realclean \

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-08-27 19:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-27 13:51 A new static binary patch H.J. Lu
1999-08-27 19:06 ` Geoff Keating
1999-08-27 19:18   ` H.J. Lu
1999-08-27 19:50     ` Geoff Keating
  -- strict thread matches above, loose matches on Subject: below --
1999-08-23 21:01 H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).