Skip to contentSkip to conversation

Cross compile?

PATCH In review Lombard, David N 4 participants 13 messages May 5, 2008 – Oct 8, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cross compile?

In util/Makefile, the bin-to-hex utility was being built with the cross-compiler, not the host compiler. This patch fixes that.

util/Makefile renamed from util/Makefile.orig +1 -4
@@ -2,10 +2,7 @@ BIN_TO_HEX:= bin/bin-to-hex
 
 $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
 	@$(MKDIR) -p $(@D)
-	$(LINK.o) -o $@ $^
+	$(BUILD_CC) $(BUILD_CFLAGS) -o $@ $<
-
-$(BIN_TO_HEX): CC=$(BUILD_CC)
-$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)
 
 dist += util/Makefile util/bin-to-hex.c
 clean += util/bin-to-hex.o $(BIN_TO_HEX)

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw

David,

Quoted 2 lines

In util/Makefile, the bin-to-hex utility was being built with the cross-compiler, not the host compiler. This patch fixes that.

We set the CC to BUILD_CC for the bin-to-hex target so it should use the host compiler currently.

What are your BUILD_CC, BUILD_CFLAGS and LDFLAGS?

Cheers,

Jeremy

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 9 lines · Jeremy Kerr

David,

Quoted 2 lines

In util/Makefile, the bin-to-hex utility was being built with the cross-compiler, not the host compiler. This patch fixes that.

We set the CC to BUILD_CC for the bin-to-hex target so it should use the host compiler currently.

What are your BUILD_CC, BUILD_CFLAGS and LDFLAGS?

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

Hi David,

Quoted 2 lines

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Let's fix the assignment then - it's been working fine here (build = i386-linux, host = powerpc-linux, target = powerpc64-linux), so I'd like to know what's breaking on your system.

What are you using for CC, BUILD_CC and LDFLAGS?

Cheers,

Jeremy

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 10 lines · Jeremy Kerr

Hi David,

Quoted 2 lines

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Let's fix the assignment then - it's been working fine here (build = i386-linux, host = powerpc-linux, target = powerpc64-linux), so I'd like to know what's breaking on your system.

What are you using for CC, BUILD_CC and LDFLAGS?

# Compiler for building kexec

  CC              = uclibc-gcc
  CPP             = uclibc-gcc -E
  LD              = ld
  AS              = as
  OBJCOPY         = objcopy
  AR              = ar

# C compiler for binaries to run during the build

  BUILD_CC        = host-gcc
  BUILD_CFLAGS    = -O2 -Wall
  TARGET_CC       = uclibc-gcc
  TARGET_CFLAGS   = -O2 -Wall
Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#5 lore raw
Quoted 9 lines · David N
Quoted 8 lines · Jeremy Kerr

Hi David,

Quoted 2 lines

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Let's fix the assignment then - it's been working fine here (build = i386-linux, host = powerpc-linux, target = powerpc64-linux), so I'd like to know what's breaking on your system.

More info:

Failure (original):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o
uclibc-gcc -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
/bin/sh: bin/bin-to-hex: /lib/ld-uClibc.so.0: bad ELF interpreter: No such file or directory
make[1]: *** [kexec/purgatory.c] Error 126

Success (patched):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o host-gcc -O2 -Wall -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
uclibc-gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/i386/include -c -MD -o kexec/purgatory.o kexec/purgatory.c

Build distro is F7
Using purpose-built gcc-3.4.6 for both uclibc-gcc and host-gcc Make is make-3.81-6.fc7

Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#6 lore raw
Quoted 32 lines · David N
Quoted 9 lines · David N
Quoted 8 lines · Jeremy Kerr

Hi David,

Quoted 2 lines

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Let's fix the assignment then - it's been working fine here (build = i386-linux, host = powerpc-linux, target = powerpc64-linux), so I'd like to know what's breaking on your system.

More info:

Failure (original):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o
uclibc-gcc -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
/bin/sh: bin/bin-to-hex: /lib/ld-uClibc.so.0: bad ELF interpreter: No such file or directory
make[1]: *** [kexec/purgatory.c] Error 126

Success (patched):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o host-gcc -O2 -Wall -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
uclibc-gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/i386/include -c -MD -o kexec/purgatory.o kexec/purgatory.c

Quoted 3 lines

Build distro is F7
Using purpose-built gcc-3.4.6 for both uclibc-gcc and host-gcc Make is make-3.81-6.fc7

Hi David,

I'm a little bit confused about how you are invoking ./configure

Signature · 7 lines
Horms


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#7 lore raw
Quoted 33 lines · Simon Horman
Quoted 32 lines · David N
Quoted 9 lines · David N
Quoted 8 lines · Jeremy Kerr

Hi David,

Quoted 2 lines

Well, note the patch *does* uses those values--it's just the assignment doesn't work.

Let's fix the assignment then - it's been working fine here (build = i386-linux, host = powerpc-linux, target = powerpc64-linux), so I'd like to know what's breaking on your system.

More info:

Failure (original):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o
uclibc-gcc -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
/bin/sh: bin/bin-to-hex: /lib/ld-uClibc.so.0: bad ELF interpreter: No such file or directory
make[1]: *** [kexec/purgatory.c] Error 126

Success (patched):

mkdir -p purgatory
uclibc-gcc --no-undefined -nostartfiles -nostdlib -nodefaultlibs -e purgatory_start -r -o purgatory/purgatory.ro purgatory/purgatory.o purgatory/printf.o purgatory/string.o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32.o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/stack.o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/console-x86.o purgatory/arch/i386/vga.o purgatory/arch/i386/pic.o purgatory/arch/i386/crashdump_backup.o purgatory/sha256.o host-gcc -O2 -Wall -o bin/bin-to-hex util/bin-to-hex.c
mkdir -p kexec
bin/bin-to-hex purgatory < purgatory/purgatory.ro > kexec/purgatory.c
uclibc-gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/i386/include -c -MD -o kexec/purgatory.o kexec/purgatory.c

Quoted 8 lines
Quoted 3 lines

Build distro is F7
Using purpose-built gcc-3.4.6 for both uclibc-gcc and host-gcc Make is make-3.81-6.fc7

Hi David,

I'm a little bit confused about how you are invoking ./configure

./configure --build=`uname -m`-linux-uclibc \
          --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
          CC=uclibc-gcc BUILD_CC=host-gcc
Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#8 lore raw
Quoted 3 lines · David N
./configure --build=`uname -m`-linux-uclibc \
         --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
         CC=uclibc-gcc BUILD_CC=host-gcc

Isn't this backwards? BUILD_CC ought to match --build, and CC ought to match --host. If you wanted a kexec binary to put in a uClibc initramfs, you should set --host for that, not --build. Right?

I've just been looking at git grep -F -w CC to decide which configure flag to use for what, if that helps.

Jamey

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw
Quoted 9 lines · Jamey Sharp
Quoted 3 lines · David N
./configure --build=`uname -m`-linux-uclibc \
         --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
         CC=uclibc-gcc BUILD_CC=host-gcc

Isn't this backwards? BUILD_CC ought to match --build, and CC ought to match --host. If you wanted a kexec binary to put in a uClibc initramfs, you should set --host for that, not --build. Right?

Here's util/Makefile, which wants bin/bin-to-hex to run on the build platform:

BIN_TO_HEX:= bin/bin-to-hex

  $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
        @$(MKDIR) -p $(@D)
        $(LINK.o) -o $@ $^

  $(BIN_TO_HEX): CC=$(BUILD_CC)
  $(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)

  dist += util/Makefile util/bin-to-hex.c
  clean += util/bin-to-hex.o $(BIN_TO_HEX)

Unless I am mistaken, this uses BUILD_CC and BIULD_CFLAGS for bin/bin-to-hex, which is run on the build platform. I patched that to:

BIN_TO_HEX:= bin/bin-to-hex

  $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
        @$(MKDIR) -p $(@D)
        $(BUILD_CC) $(BUILD_CFLAGS) -o $@ $<

  dist += util/Makefile util/bin-to-hex.c
  clean += util/bin-to-hex.o $(BIN_TO_HEX)

otherwise it used the uClibc-based tools, which cannot run on the current glibc-based platform (F7).

Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#10 lore raw
In reply to Lombard, David N

Hi David,

(sorry about the late reply, been on holidays for the last 3 weeks..)

Quoted 3 lines
./configure --build=`uname -m`-linux-uclibc \
          --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
          CC=uclibc-gcc BUILD_CC=host-gcc

Ah, there's the problem. You're specifying CC on the configure line, which is overriding it for *everything*. Which is why the CC=$(BUILD_CC) assignment in util/Makefile isn't working for you.

I'll see if I can work out a proper fix...

Also, why are you setting --build to -uclibc?

Cheers,

Jeremy

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw
Quoted 11 lines · Jeremy Kerr

Hi David,

(sorry about the late reply, been on holidays for the last 3 weeks..)

Quoted 3 lines
./configure --build=`uname -m`-linux-uclibc \
          --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
          CC=uclibc-gcc BUILD_CC=host-gcc

Ah, there's the problem. You're specifying CC on the configure line, which is overriding it for *everything*. Which is why the CC=$(BUILD_CC) assignment in util/Makefile isn't working for you.

I'm perfectly happy to admit I've horked this...

Quoted 3 lines

I'll see if I can work out a proper fix...

Also, why are you setting --build to -uclibc?

Some of the above came from kboot; everything else is my own fault :)

kexec is being built on a glibc-based x86 for use on a uclibc-based x86.

Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#12 lore raw
Quoted 15 lines · David N
Quoted 11 lines · Jeremy Kerr

Hi David,

(sorry about the late reply, been on holidays for the last 3 weeks..)

Quoted 3 lines
./configure --build=`uname -m`-linux-uclibc \
          --host=`uname -m` --prefix=/home/dnl/kboot-11/root \
          CC=uclibc-gcc BUILD_CC=host-gcc

Ah, there's the problem. You're specifying CC on the configure line, which is overriding it for *everything*. Which is why the CC=$(BUILD_CC) assignment in util/Makefile isn't working for you.

I'm perfectly happy to admit I've horked this...

Quoted 8 lines
Quoted 3 lines

I'll see if I can work out a proper fix...

Also, why are you setting --build to -uclibc?

Some of the above came from kboot; everything else is my own fault :)

kexec is being built on a glibc-based x86 for use on a uclibc-based x86.

I know that this is a bit of a blast from the past, but I believe that this has been fixed by Jeremy.

Signature · 9 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec