* CFLAGS are for C compilers and other Unix traditions
[not found] <E1FhcWV-0004n6-Dm@host-192-168-0-1-bcn-london>
@ 2006-05-21 2:58 ` John D. Ramsdell
2006-05-21 8:48 ` Keir Fraser
0 siblings, 1 reply; 7+ messages in thread
From: John D. Ramsdell @ 2006-05-21 2:58 UTC (permalink / raw)
To: xen-devel
I recognize the vitality of youth, but please allow me to plug some
Unix traditions. There is a long tradition on how to write
makefiles. Many of these traditions are encoded in the default rules
that are part of GNU make. You can see them with the command:
$ make -p
If you execute this command, you will note that the rule for
assembling .S files is:
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
Note that you don't give the assembler CFLAGS. It's not a C
compiler.
The default rules use TARGET_MACH in a very well thought out way.
Please use TARGET_MACH in a manor consistent with GNU make's default
rules.
Another long standing Unix tradition is that applications do not
depend on the path environment variable currently in effect. Relying
on a path means that a user of an application gets screwy results if
they use a non-standard path. More importantly, an application that
depends on paths does not allow one to install more than one version
of that application.
The Xen application xm fails respect this Unix tradition. Multiple
installations of differing versions of xm will get very confused.
John
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: CFLAGS are for C compilers and other Unix traditions
2006-05-21 2:58 ` CFLAGS are for C compilers and other Unix traditions John D. Ramsdell
@ 2006-05-21 8:48 ` Keir Fraser
2006-05-21 16:40 ` John D. Ramsdell
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Keir Fraser @ 2006-05-21 8:48 UTC (permalink / raw)
To: John D. Ramsdell; +Cc: xen-devel
On 21 May 2006, at 03:58, John D. Ramsdell wrote:
> If you execute this command, you will note that the rule for
> assembling .S files is:
>
> COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
>
> Note that you don't give the assembler CFLAGS. It's not a C
> compiler.
We fixed this for Xen itself some time ago. If there are other places
in the tree that do this (maybe minios?), please do provide a patch.
-- Keir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: CFLAGS are for C compilers and other Unix traditions
2006-05-21 8:48 ` Keir Fraser
@ 2006-05-21 16:40 ` John D. Ramsdell
2006-05-21 17:12 ` John D. Ramsdell
2006-05-22 10:31 ` [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH John D. Ramsdell
2 siblings, 0 replies; 7+ messages in thread
From: John D. Ramsdell @ 2006-05-21 16:40 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
Keir Fraser <Keir.Fraser@cl.cam.ac.uk> writes:
> On 21 May 2006, at 03:58, John D. Ramsdell wrote:
>
> > If you execute this command, you will note that the rule for
> > assembling .S files is:
> >
> > COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c
> >
> > Note that you don't give the assembler CFLAGS. It's not a C
> > compiler.
>
> We fixed this for Xen itself some time ago. If there are other places
> in the tree that do this (maybe minios?), please do provide a patch.
The Mini-OS makefile was recently patched so as to include the
following rules:
%.o: %.c $(HDRS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o: %.S $(HDRS) Makefile
$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
Note the rules fail to include $(TARGET_MACH), which is part of the
default rule for COMPILE.S, and $(TARGET_ARCH), which is normally
part of COMPILE.c.
When the appropriate GCC backends are installed on an i386 32-bit
machine, the $(TARGET_MACH) flags, and the $(TARGET_ARCH) flags can be
used to produce a Mini-OS elf file for both the 32 and 64 i386
architectures. You don't have to put your cross compilers in separate
locations.
I decided to test the use of Mini-OS as a library. My test
application included just one file, app.c, and it resided in a
directory outside the Xen sources. I wrote the obvious Makefile, and
used the default rule to build app.o from app.c.
This Makefile fails, of course, because $(TARGET_ARCH) is set to
x86_32 by Config.mk, and the default rule is:
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
I hadn't tracked down the source of my problem before I sent my post
last night. I somehow thought that COMPILE.c used $(TARGET_MACH),
instead of $(TARGET_ARCH), and therefore thought a fix was plausible.
I now see that modifying Xen to work with the default rules is a big
pain. On the plus side, tracking down this problem forced me to
look at Config.mk, and see I can select a cross-compiler by setting
CROSS_COMPILER to the bin directory of my cross compiler, rather than
setting my path.
John
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: CFLAGS are for C compilers and other Unix traditions
2006-05-21 8:48 ` Keir Fraser
2006-05-21 16:40 ` John D. Ramsdell
@ 2006-05-21 17:12 ` John D. Ramsdell
2006-05-22 10:31 ` [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH John D. Ramsdell
2 siblings, 0 replies; 7+ messages in thread
From: John D. Ramsdell @ 2006-05-21 17:12 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
The note I sent contained a misstatement. TARGET_ARCH is being set in
the Mini-OS Makefile, not ../../Config.mk. I meant to say that to get
all Xen Makefiles to use TARGET_ARCH and TARGET_MACH as they were
intended would be a pain. Target information is currently being
placed into CFLAGS and LDFLAGS, and one would have to be careful to
separate the information correctly. Not worth it.
John
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH
2006-05-21 8:48 ` Keir Fraser
2006-05-21 16:40 ` John D. Ramsdell
2006-05-21 17:12 ` John D. Ramsdell
@ 2006-05-22 10:31 ` John D. Ramsdell
2006-05-22 13:20 ` Keir Fraser
2 siblings, 1 reply; 7+ messages in thread
From: John D. Ramsdell @ 2006-05-22 10:31 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
[-- Attachment #1: Type: text/plain, Size: 339 bytes --]
Keir Fraser <Keir.Fraser@cl.cam.ac.uk> writes:
> We fixed this for Xen itself some time ago. If there are other places
> in the tree that do this (maybe minios?), please do provide a patch.
To facilitate cut-and-paste of portions of the Mini-OS Makefile into
other Makefiles, this patch renames TARGET_ARCH to MINIOS_TARGET_ARCH.
John
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH --]
[-- Type: text/x-patch, Size: 3006 bytes --]
Only in xxen-unstable/extras/mini-os/console: console.o
Only in xxen-unstable/extras/mini-os/console: xencons_ring.o
Only in xxen-unstable/extras/mini-os: events.o
Only in xxen-unstable/extras/mini-os: hypervisor.o
Only in xxen-unstable/extras/mini-os/include: xen
Only in xxen-unstable/extras/mini-os: kernel.o
Only in xxen-unstable/extras/mini-os/lib: math.o
Only in xxen-unstable/extras/mini-os/lib: printf.o
Only in xxen-unstable/extras/mini-os/lib: string.o
Only in xxen-unstable/extras/mini-os/lib: xmalloc.o
Only in xxen-unstable/extras/mini-os: libminios.a
diff -ur axen-unstable/extras/mini-os/Makefile xxen-unstable/extras/mini-os/Makefile
--- axen-unstable/extras/mini-os/Makefile 2006-05-22 06:08:42.000000000 -0400
+++ xxen-unstable/extras/mini-os/Makefile 2006-05-22 06:24:00.000000000 -0400
@@ -2,8 +2,8 @@
include $(CURDIR)/../../Config.mk
-# Set TARGET_ARCH
-override TARGET_ARCH := $(XEN_TARGET_ARCH)
+# Set MINIOS_TARGET_OS
+override MINIOS_TARGET_OS := $(XEN_TARGET_ARCH)
# NB. '-Wcast-qual' is nasty, so I omitted it.
CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
@@ -13,14 +13,14 @@
ASFLAGS = -D__ASSEMBLY__
LDLIBS = -L. -lminios
-LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
+LDFLAGS := -N -T minios-$(MINIOS_TARGET_OS).lds
-ifeq ($(TARGET_ARCH),x86_32)
+ifeq ($(MINIOS_TARGET_OS),x86_32)
CFLAGS += -m32 -march=i686
LDFLAGS += -m elf_i386
endif
-ifeq ($(TARGET_ARCH),x86_64)
+ifeq ($(MINIOS_TARGET_OS),x86_64)
CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
CFLAGS += -fno-asynchronous-unwind-tables
LDFLAGS += -m elf_x86_64
@@ -34,7 +34,7 @@
TARGET := mini-os
-HEAD := $(TARGET_ARCH).o
+HEAD := $(MINIOS_TARGET_OS).o
OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
@@ -54,7 +54,7 @@
ar r libminios.a $(HEAD) $(OBJS)
$(TARGET): links libminios.a $(HEAD)
- $(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o $@.elf
+ $(LD) $(LDFLAGS) $(TARGET_ARCH) $(HEAD) $(LDLIBS) -o $@.elf
gzip -f -9 -c $@.elf >$@.gz
.PHONY: clean
@@ -65,10 +65,10 @@
find . -type l | xargs rm -f
%.o: %.c $(HDRS) Makefile
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
%.o: %.S $(HDRS) Makefile
- $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
+ $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c $< -o $@
define all_sources
( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
@@ -78,4 +78,3 @@
cscope:
$(all_sources) > cscope.files
cscope -k -b -q
-
Only in xxen-unstable/extras/mini-os: Makefile~
Only in xxen-unstable/extras/mini-os: mini-os.elf
Only in xxen-unstable/extras/mini-os: mini-os.gz
Only in xxen-unstable/extras/mini-os: mm.o
Only in xxen-unstable/extras/mini-os: sched.o
Only in xxen-unstable/extras/mini-os: time.o
Only in xxen-unstable/extras/mini-os: traps.o
Only in xxen-unstable/extras/mini-os: x86_32.o
Only in xxen-unstable/extras/mini-os/xenbus: xenbus.o
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH
2006-05-22 10:31 ` [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH John D. Ramsdell
@ 2006-05-22 13:20 ` Keir Fraser
2006-05-22 16:47 ` John D. Ramsdell
0 siblings, 1 reply; 7+ messages in thread
From: Keir Fraser @ 2006-05-22 13:20 UTC (permalink / raw)
To: John D. Ramsdell; +Cc: xen-devel
On 22 May 2006, at 11:31, John D. Ramsdell wrote:
>> We fixed this for Xen itself some time ago. If there are other places
>> in the tree that do this (maybe minios?), please do provide a patch.
>
> To facilitate cut-and-paste of portions of the Mini-OS Makefile into
> other Makefiles, this patch renames TARGET_ARCH to MINIOS_TARGET_ARCH.
First, you renamed to MINIOS_TARGET_OS, not _ARCH, which makes no
sense. Second, you added references to TARGET_ARCH and TARGET_MACH to
rule patterns, which seems unnecessary and might have unwanted side
effects.
-- Keir
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH
2006-05-22 13:20 ` Keir Fraser
@ 2006-05-22 16:47 ` John D. Ramsdell
0 siblings, 0 replies; 7+ messages in thread
From: John D. Ramsdell @ 2006-05-22 16:47 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel
Keir Fraser <Keir.Fraser@cl.cam.ac.uk> writes:
> First, you renamed to MINIOS_TARGET_OS, not _ARCH, which makes no
> sense. Second, you added references to TARGET_ARCH and TARGET_MACH to
> rule patterns, which seems unnecessary and might have unwanted side
> effects.
Please ignore this patch request. No real need for change.
John
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-05-22 16:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1FhcWV-0004n6-Dm@host-192-168-0-1-bcn-london>
2006-05-21 2:58 ` CFLAGS are for C compilers and other Unix traditions John D. Ramsdell
2006-05-21 8:48 ` Keir Fraser
2006-05-21 16:40 ` John D. Ramsdell
2006-05-21 17:12 ` John D. Ramsdell
2006-05-22 10:31 ` [PATCH] Mini-OS Makefile TARGET_ARCH becomes MINIOS_TARGET_ARCH John D. Ramsdell
2006-05-22 13:20 ` Keir Fraser
2006-05-22 16:47 ` John D. Ramsdell
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.