All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] user-cr: Eliminate SUBARCH from Makefile
@ 2010-02-26 20:37 Matt Helsley
       [not found] ` <0c6c11c99f939c74b86893d5eac268ce5c612fe7.1267216666.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Matt Helsley @ 2010-02-26 20:37 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Linux-Containers, Nathan Lynch

[ Depends on recent series of non-RFC Makefile patches ]

SUBARCH is gross. We shouldn't need to detect the arch to compile to
using uname. It's bad practice because we could be using a cross compiler,
or someone may (gag) autoconfiscate this tree. If we must select a true
subarch, we should just let builders set -mXX in CFLAGS.

This patch tries to build all of the clone_*.[cSs] files. Any builds
that fail are quietly ignored and don't get used. One that succeeds
gets hardlinked to clone.a and subsequently linked into libeclone.a

This makes SUBARCH unnecessary.

Only tested on x86-32 so far. This also doesn't properly add clone.a
to libclone.a for some reason.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 Makefile |   55 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/Makefile b/Makefile
index 60ddccd..03acea7 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,6 @@ CKPT_HEADERS = include/linux/checkpoint.h \
 		include/linux/checkpoint_hdr.h \
 		include/asm/checkpoint_hdr.h
 
-# detect architecture (for eclone)
-SUBARCH = $(patsubst i%86,x86_32,$(shell uname -m))
-
 # compile with debug ?
 DEBUG = -DCHECKPOINT_DEBUG
 
@@ -42,24 +39,44 @@ $(LIB_ECLONE):
 # restart needs to be thread-safe
 restart: CFLAGS += -D__REENTRANT -pthread
 
+# Set CFLAGS to -m32 or -m64 to select a non-default subarch.
+# Hence we don't need the commented out CFLAGS-setting rules
+# immediately below.
+
+# clone_ppc.o: CFLAGS += -m32
+clone_ppc_.o: ASFLAGS += -m32
+# clone_ppc64.o: CFLAGS += -m64
+clone_ppc64_.o: ASFLAGS += -m64
+
+# powerpc clone.a requires two object files
+clone_ppc.a: clone_ppc_.o clone_ppc.o
+	$(AR) ruv $@ $^
+
+clone_ppc64.a: clone_ppc64_.o clone_ppc64.o
+	$(AR) ruv $@ $^
+
+# The remaining arch's clone.a all share the following rule
+%.a: %.o
+	$(AR) ruv $@ $^
+
+# Unlike normal rule dependencies, we want to link libeclone with the
+# object files that build successfully and ignore the rest. Normally
+# we do this by testing which will build and then setting a variable
+# for the dependency to use. Here we just depend on all the real source
+# files and hardlink the result of a successful build.
+clone.a: $(shell echo clone_*.[cSs])
+	@$(MAKE) -s clone_x86_32.a && ln clone_x86_32.a clone.a || /bin/true
+	@$(MAKE) -s clone_x86_64.a && ln clone_x86_64.a clone.a || /bin/true
+	@$(MAKE) -s clone_ppc.a && ln clone_ppc.a clone.a || /bin/true
+	@$(MAKE) -s clone_ppc64.a && ln clone_ppc64.o clone.a || /bin/true
+	@$(MAKE) -s clone_s390x.a && ln clone_s390x.o clone.a || /bin/true
+
 # eclone() is architecture specific
-ifneq ($(SUBARCH),)
-$(ECLONE_PROGS): $(LIB_ECLONE) 
+# TODO why doesn't clone.a link properly into libeclone.a??
+$(ECLONE_PROGS): $(LIB_ECLONE) clone.a
 $(ECLONE_PROGS): CFLAGS += -DARCH_HAS_ECLONE
-$(LIB_ECLONE): clone_$(SUBARCH).o genstack.o
-endif
-
-# on powerpc, need also assembly file
-ifeq ($(SUBARCH),ppc)
-CFLAGS += -m32
-ASFLAGS += -m32
-$(LIB_ECLONE): clone_$(SUBARCH)_.o
-endif
-ifeq ($(SUBARCH),ppc64)
-CFLAGS += -m64
-ASFLAGS += -m64
-$(LIB_ECLONE): clone_$(SUBARCH)_.o
-endif
+$(LIB_ECLONE): clone.a genstack.o
+
 
 # ckptinfo dependencies
 ckptinfo: ckptinfo_types.o
-- 
1.6.3.3

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

* Re: [PATCH] [RFC] user-cr: Eliminate SUBARCH from Makefile
       [not found] ` <0c6c11c99f939c74b86893d5eac268ce5c612fe7.1267216666.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-02-26 20:54   ` Nathan Lynch
       [not found]     ` <1267217669.15300.118.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Lynch @ 2010-02-26 20:54 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Linux-Containers

On Fri, 2010-02-26 at 12:37 -0800, Matt Helsley wrote:
> [ Depends on recent series of non-RFC Makefile patches ]
> 
> SUBARCH is gross. We shouldn't need to detect the arch to compile to
> using uname. It's bad practice because we could be using a cross compiler,
> or someone may (gag) autoconfiscate this tree. If we must select a true
> subarch, we should just let builders set -mXX in CFLAGS.
> 
> This patch tries to build all of the clone_*.[cSs] files. Any builds
> that fail are quietly ignored and don't get used. One that succeeds
> gets hardlinked to clone.a and subsequently linked into libeclone.a

Hmm, I think detecting the architecture via uname is fine as long as the
user is able to override it (make SUBARCH=foo).

I don't think trying to compile all of clone_* is going to be a good
practice.  For one thing, gcc -m64 on powerpc happily accepted the
32-bit clone wrapper the last time I tried it, hence the #error
directives in clone_ppc*.S.

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

* [PATCH user-cr] User can override SUBARCH for cross-compilation
       [not found]     ` <1267217669.15300.118.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-03-01 15:50       ` Oren Laadan
       [not found]         ` <1267458606-1622-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Oren Laadan @ 2010-03-01 15:50 UTC (permalink / raw)
  To: Matt Helsley
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Nathan Lynch

Detecting the architecture via uname is fine as long as the user is
able to override it (make SUBARCH=foo).

Signed-of-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
---
 Makefile |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 60ddccd..64b5f73 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,11 @@
+# *DOCUMENTATION*
+#
+# List of environment variables that may be set by caller:
+#  KERNELSRC	- path of kernel sources (def: ../linux)
+#  SUBARCH	- sub-architecture (def: extract with 'uname')
+#  PREFIX	- prefix path for installation (def: /usr/local)
+#
+
 KERNELSRC ?= ../linux
 
 CKPT_INCLUDE = -I./include
@@ -6,7 +14,7 @@ CKPT_HEADERS = include/linux/checkpoint.h \
 		include/asm/checkpoint_hdr.h
 
 # detect architecture (for eclone)
-SUBARCH = $(patsubst i%86,x86_32,$(shell uname -m))
+SUBARCH ?= $(patsubst i%86,x86_32,$(shell uname -m))
 
 # compile with debug ?
 DEBUG = -DCHECKPOINT_DEBUG
-- 
1.6.3.3

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

* Re: [PATCH user-cr] User can override SUBARCH for cross-compilation
       [not found]         ` <1267458606-1622-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
@ 2010-03-01 17:44           ` Nathan Lynch
       [not found]             ` <1267465468.4347.6.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Lynch @ 2010-03-01 17:44 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hey Oren,

On Mon, 2010-03-01 at 10:50 -0500, Oren Laadan wrote:
> Detecting the architecture via uname is fine as long as the user is
> able to override it (make SUBARCH=foo).
> 
> Signed-of-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
> ---
>  Makefile |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 60ddccd..64b5f73 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1,3 +1,11 @@
> +# *DOCUMENTATION*
> +#
> +# List of environment variables that may be set by caller:
> +#  KERNELSRC	- path of kernel sources (def: ../linux)
> +#  SUBARCH	- sub-architecture (def: extract with 'uname')
> +#  PREFIX	- prefix path for installation (def: /usr/local)
> +#
> +
>  KERNELSRC ?= ../linux
>  
>  CKPT_INCLUDE = -I./include
> @@ -6,7 +14,7 @@ CKPT_HEADERS = include/linux/checkpoint.h \
>  		include/asm/checkpoint_hdr.h
>  
>  # detect architecture (for eclone)
> -SUBARCH = $(patsubst i%86,x86_32,$(shell uname -m))
> +SUBARCH ?= $(patsubst i%86,x86_32,$(shell uname -m))

I didn't mean to imply that the user-cr Makefile didn't already honor
the user's SUBARCH setting on the command line.  That is, "make
SUBARCH=ppc" works fine already, since command line assignment of
variables overrides assignment within the Makefile.

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

* Re: [PATCH user-cr] User can override SUBARCH for cross-compilation
       [not found]             ` <1267465468.4347.6.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-03-01 19:05               ` Oren Laadan
       [not found]                 ` <4B8C1009.7090905-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Oren Laadan @ 2010-03-01 19:05 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA



Nathan Lynch wrote:
> Hey Oren,
> 
> On Mon, 2010-03-01 at 10:50 -0500, Oren Laadan wrote:
>> Detecting the architecture via uname is fine as long as the user is
>> able to override it (make SUBARCH=foo).
>>
>> Signed-of-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
>> ---
>>  Makefile |   10 +++++++++-
>>  1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 60ddccd..64b5f73 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1,3 +1,11 @@
>> +# *DOCUMENTATION*
>> +#
>> +# List of environment variables that may be set by caller:
>> +#  KERNELSRC	- path of kernel sources (def: ../linux)
>> +#  SUBARCH	- sub-architecture (def: extract with 'uname')
>> +#  PREFIX	- prefix path for installation (def: /usr/local)
>> +#
>> +
>>  KERNELSRC ?= ../linux
>>  
>>  CKPT_INCLUDE = -I./include
>> @@ -6,7 +14,7 @@ CKPT_HEADERS = include/linux/checkpoint.h \
>>  		include/asm/checkpoint_hdr.h
>>  
>>  # detect architecture (for eclone)
>> -SUBARCH = $(patsubst i%86,x86_32,$(shell uname -m))
>> +SUBARCH ?= $(patsubst i%86,x86_32,$(shell uname -m))
> 
> I didn't mean to imply that the user-cr Makefile didn't already honor
> the user's SUBARCH setting on the command line.  That is, "make
> SUBARCH=ppc" works fine already, since command line assignment of
> variables overrides assignment within the Makefile.
> 

Using "?=" allows a user to set SUBARCH as an environment variable
(and not have to repeatedly type it). Sinmple "=" does not pick up
a default value from the environment.

I'll fix the commit message to be more accurate.

Oren

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

* Re: [PATCH user-cr] User can override SUBARCH for cross-compilation
       [not found]                 ` <4B8C1009.7090905-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
@ 2010-03-01 19:16                   ` Nathan Lynch
  0 siblings, 0 replies; 6+ messages in thread
From: Nathan Lynch @ 2010-03-01 19:16 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On Mon, 2010-03-01 at 14:05 -0500, Oren Laadan wrote:
> Using "?=" allows a user to set SUBARCH as an environment variable
> (and not have to repeatedly type it). Sinmple "=" does not pick up
> a default value from the environment.

That is true.


> I'll fix the commit message to be more accurate.

Thanks!

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

end of thread, other threads:[~2010-03-01 19:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-26 20:37 [PATCH] [RFC] user-cr: Eliminate SUBARCH from Makefile Matt Helsley
     [not found] ` <0c6c11c99f939c74b86893d5eac268ce5c612fe7.1267216666.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-02-26 20:54   ` Nathan Lynch
     [not found]     ` <1267217669.15300.118.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-01 15:50       ` [PATCH user-cr] User can override SUBARCH for cross-compilation Oren Laadan
     [not found]         ` <1267458606-1622-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-03-01 17:44           ` Nathan Lynch
     [not found]             ` <1267465468.4347.6.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-01 19:05               ` Oren Laadan
     [not found]                 ` <4B8C1009.7090905-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-03-01 19:16                   ` Nathan Lynch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.