Cross-compiling GRUB
Hi,
At the moment I am compiling GRUB on one PPC system and running it on another. At the moment this is very unproductive for me and making it hard, if not impossible, to do any testing. So I set up a cross-compiler so I can compile GRUB 2 for the PPC on my AMD64.
There are three problems with GRUB 2 CVS ATM. Most importantly is that grub-mkimage can not be run on the AMD64 because it is little endian. This patch fixed the endian issues in grub-mkimage and it all works now. Another issue is that some check in configure.ac was wrong. The last is that genmk.rb did not work correctly because it produces PPC .o files which it tries to link with the AMD64 linker. :)
I think all these fixes are too obvious and should not cause any copyright problems. Okuji, do you agree with this?
Johan, Hollis, this patch touches some of your files. It would be nice if both of you could have a quick look at this patch. :)
Thanks,
Marco
2005-04-10 Marco Gerards <[email protected]>
* configure.ac: Fix the test for cross-compiling.
* genmk.rb (Program): Use $(CC)' instead of $(BUILD_CC)'. Don't define GRUB_UTIL anymore.
* util/powerpc/ieee1275/grub-mkimage.c (load_note): Endian fixes so this function works on other systems than just big endian. (load_modules): Likewise.
(add_segments): Likewise.
Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.9
configure.ac +1 -1
@@ -109,7 +109,7 @@ AC_CHECK_TOOL(LD, ld) AC_PATH_PROG(RUBY, ruby) # For cross-compiling. -if test "x$build" = "x$host"; then +if test "x$build" != "x$host"; then AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc], [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])]) else
Index: genmk.rb
===================================================================
RCS file: /cvsroot/grub/grub2/genmk.rb,v
retrieving revision 1.12
genmk.rb +3 -3
@@ -236,7 +236,7 @@ class Program MOSTLYCLEANFILES += #{deps_str} #{@name}: #{objs_str} - $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS) + $(CC) -o $@ $^ $(LDFLAGS) $(#{prefix}_LDFLAGS) " + objs.collect_with_index do |obj, i| src = sources[i]
@@ -245,11 +245,11 @@ MOSTLYCLEANFILES += #{deps_str} dir = File.dirname(src) "#{obj}: #{src} - $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $< + $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $< #{dep}: #{src} set -e; \ - $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \ + $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -M $< \ | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \ [ -s $@ ] || rm -f $@
Index: util/powerpc/ieee1275/grub-mkimage.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/powerpc/ieee1275/grub-mkimage.c,v retrieving revision 1.2
powerpc/ieee1275/grub-mkimage.c +45 -34
145 lines not on this page · raw message
Quoted 3 lines · Marco Gerards
Johan, Hollis, this patch touches some of your files. It would be nice if both of you could have a quick look at this patch. :)
From a quick skim, it looks fine to me.
-Hollis
Quoted 2 lines · Marco Gerards
I think all these fixes are too obvious and should not cause any copyright problems. Okuji, do you agree with this?
It is not obvious. Please understand that "obvious" in copyright laws means "small" in most cases. Haven't you talked with your employer about GRUB yet?
Okuji
Quoted 6 lines · Yoshinori K. Okuji
Quoted 2 lines · Marco Gerards
I think all these fixes are too obvious and should not cause any copyright problems. Okuji, do you agree with this?
It is not obvious. Please understand that "obvious" in copyright laws means "small" in most cases. Haven't you talked with your employer about GRUB yet?
I thought obvious means both small and that there is just a single solution possible.
--
Marco
Quoted 6 lines · Yoshinori K. Okuji
Quoted 2 lines · Marco Gerards
I think all these fixes are too obvious and should not cause any copyright problems. Okuji, do you agree with this?
It is not obvious. Please understand that "obvious" in copyright laws means "small" in most cases. Haven't you talked with your employer about GRUB yet?
I contacted the FSF about this patch and explained my personal situation. They told me it is legally ok to apply this patch.
If there are no objections, I will apply this patch this Tuesday.
Thanks,
Marco
Quoted 2 lines · Marco Gerards
I contacted the FSF about this patch and explained my personal situation. They told me it is legally ok to apply this patch.
Good. :)
Okuji
Quoted 5 lines · Marco Gerards
At the moment I am compiling GRUB on one PPC system and running it on another. At the moment this is very unproductive for me and making it hard, if not impossible, to do any testing. So I set up a cross-compiler so I can compile GRUB 2 for the PPC on my AMD64.
I have a powerpc64-unknown-linux-gnu toolchain (which can produce ppc32 binaries), but configure is being very annoying. I think I need to be able to specify host and cross-compile prefix separately (like Linux kbuild does). In other words, configure --crosscompiler=powerpc64-unknown-linux-gnu- --host=powerpc-unknown-linux-gnu.
How did you run configure?
-Hollis