Skip to contentSkip to conversation

klibc: klcc: consider --sysroot option and override gcc-cross encoded sysroot

PATCH Superseded Andrea Adami 2 participants 3 messages Sep 1, 2014 – Sep 16, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 klibc: klcc: consider --sysroot option and override gcc-cross encoded sysroot

For the recipes built with klcc-cross it is necessary to
pass --sysroot otherwise we default to the one encoded in gcc-cross which actually is the 'first one' built.
The issue was revealed when building for armv4 after having built for armv5te:
the produced binaries did contain Illegal Instruction (bx lr).

---
 meta-initramfs/classes/klibc.bbclass                       |  4 ++--
 .../klibc/klibc-2.0.4/klcc-consider-sysroot.patch          | 14 ++++++++++++++
 meta-initramfs/recipes-devtools/klibc/klibc.inc            |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
meta-initramfs/classes/klibc.bbclass +2 -2
index ca741cd..8690472 100644
@@ -4,8 +4,8 @@ DEPENDS =+ "klcc-cross"
 # Default for klcc is to build static binaries.
 # Set CC = "${TARGET_PREFIX}klcc -shared" to build the dynamic version.
 
-export CC = "${TARGET_PREFIX}klcc"
-export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc -march=armv4 -mthumb-interwork"
+export CC = "${TARGET_PREFIX}klcc --sysroot=${STAGING_DIR_TARGET}"
+export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc --sysroot=${STAGING_DIR_TARGET} -march=armv4 -mthumb-interwork"
 
 export CPP = "${CC} -E"
 
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch new file +14 -0
new file mode 100644
index 0000000..9bc4835
@@ -0,0 +1,14 @@
+diff --git a/klcc/klcc.in b/klcc/klcc.in
+index 43d0984..61e9385 100644
+--- a/klcc/klcc.in
++++ b/klcc/klcc.in
+@@ -204,6 +204,9 @@ while ( defined($a = shift(@ARGV)) ) {
+ 	# Libraries
+ 	push(@libs, $a);
+ 	push(@libs, shift(@ARGV)) if ( $2 eq '' );
++    } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
++	# Override gcc encoded sysroot
++	push(@ccopt, $a);
+     } else {
+ 	die "$0: unknown option: $a\n";
+     }
meta-initramfs/recipes-devtools/klibc/klibc.inc +1 -0
index 0209b20..f3e9972 100644
@@ -16,6 +16,7 @@ SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \
                                     "
 SRC_URI += "file://klibc-linux-libc-dev.patch \
             file://staging.patch \
+            file://klcc-consider-sysroot.patch \
             "
 
 S = "${WORKDIR}/git"
Signature · 1 line
1.9.1
#1 lore raw
Quoted 33 lines · Andrea Adami

For the recipes built with klcc-cross it is necessary to
pass --sysroot otherwise we default to the one encoded in gcc-cross which actually is the 'first one' built.
The issue was revealed when building for armv4 after having built for armv5te:
the produced binaries did contain Illegal Instruction (bx lr).

Signed-off-by Andrea Adami <[email protected] <javascript:;>>
---
 meta-initramfs/classes/klibc.bbclass                       |  4 ++--
 .../klibc/klibc-2.0.4/klcc-consider-sysroot.patch          | 14
++++++++++++++
 meta-initramfs/recipes-devtools/klibc/klibc.inc            |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644

meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch

meta-initramfs/classes/klibc.bbclass +2 -4
index ca741cd..8690472 100644
@@ -4,8 +4,8 @@ DEPENDS =+ "klcc-cross"
 # Default for klcc is to build static binaries.
 # Set CC = "${TARGET_PREFIX}klcc -shared" to build the dynamic version.
 
-export CC = "${TARGET_PREFIX}klcc"
-export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc -march=armv4
-mthumb-interwork"
+export CC = "${TARGET_PREFIX}klcc --sysroot=${STAGING_DIR_TARGET}"
+export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc
--sysroot=${STAGING_DIR_TARGET} -march=armv4 -mthumb-interwork"
 
Quoted 1 line

May be you can use TOOLCHAIN_OPTIONS

here

export CPP = "${CC} -E"

Quoted 47 lines

diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch new file mode 100644
index 0000000..9bc4835
--- /dev/null
+++
b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch

meta-initramfs/classes/klibc.bbclass +14 -0
@@ -0,0 +1,14 @@
+diff --git a/klcc/klcc.in b/klcc/klcc.in
+index 43d0984..61e9385 100644
+--- a/klcc/klcc.in
++++ b/klcc/klcc.in
+@@ -204,6 +204,9 @@ while ( defined($a = shift(@ARGV)) ) {
+       # Libraries
+       push(@libs, $a);
+       push(@libs, shift(@ARGV)) if ( $2 eq '' );
++    } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
++      # Override gcc encoded sysroot
++      push(@ccopt, $a);
+     } else {
+       die "$0: unknown option: $a\n";
+     }
meta-initramfs/recipes-devtools/klibc/klibc.inc +1 -0
index 0209b20..f3e9972 100644
@@ -16,6 +16,7 @@ SRC_URI_append_linux-uclibceabi = "
 file://klibc-config-eabi.patch \
                                     "
 SRC_URI += "file://klibc-linux-libc-dev.patch \
             file://staging.patch \
+            file://klcc-consider-sysroot.patch \
             "
 

S = "${WORKDIR}/git"
--
1.9.1

--
_______________________________________________
Openembedded-devel mailing list [email protected] <javascript:;>
http://lists.openembedded.org/mailman/listinfo/openembedded-devel

#2 lore raw
Quoted 35 lines · Khem Raj
Quoted 33 lines · Andrea Adami

For the recipes built with klcc-cross it is necessary to
pass --sysroot otherwise we default to the one encoded in gcc-cross which actually is the 'first one' built.
The issue was revealed when building for armv4 after having built for armv5te:
the produced binaries did contain Illegal Instruction (bx lr).

Signed-off-by Andrea Adami <[email protected] <javascript:;>>
---
 meta-initramfs/classes/klibc.bbclass                       |  4 ++--
 .../klibc/klibc-2.0.4/klcc-consider-sysroot.patch          | 14
++++++++++++++
 meta-initramfs/recipes-devtools/klibc/klibc.inc            |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644

meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch

meta-initramfs/classes/klibc.bbclass +2 -4
index ca741cd..8690472 100644
@@ -4,8 +4,8 @@ DEPENDS =+ "klcc-cross"
 # Default for klcc is to build static binaries.
 # Set CC = "${TARGET_PREFIX}klcc -shared" to build the dynamic version.
 
-export CC = "${TARGET_PREFIX}klcc"
-export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc -march=armv4
-mthumb-interwork"
+export CC = "${TARGET_PREFIX}klcc --sysroot=${STAGING_DIR_TARGET}"
+export CC_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc
--sysroot=${STAGING_DIR_TARGET} -march=armv4 -mthumb-interwork"
 
Quoted 3 lines
Quoted 1 line

May be you can use TOOLCHAIN_OPTIONS

here

Yes, if you advise I'd use that.

I am a bit scared looking at the mangling happening to TOOLCHAIN_OPTIONS...
http://cgit.openembedded.org/openembedded-core/log/?qt=grep&q=TOOLCHAIN_OPTIONS

Just few months ago klcc-cross recipe was inheriting cross so I can imagine it would have fallen
(a195950 cross.bbclass: Set TOOLCHAIN_OPTIONS to an empty value instead of duplicating...)

I can guess what will happen to klibc-bbclass if that value will be changed...

Thanks for reviewing
Cheers

Andrea

Quoted 54 lines

export CPP = "${CC} -E"

Quoted 41 lines

diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch new file mode 100644
index 0000000..9bc4835
--- /dev/null
+++
b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch

meta-initramfs/classes/klibc.bbclass +14 -0
@@ -0,0 +1,14 @@
+diff --git a/klcc/klcc.in b/klcc/klcc.in
+index 43d0984..61e9385 100644
+--- a/klcc/klcc.in
++++ b/klcc/klcc.in
+@@ -204,6 +204,9 @@ while ( defined($a = shift(@ARGV)) ) {
+       # Libraries
+       push(@libs, $a);
+       push(@libs, shift(@ARGV)) if ( $2 eq '' );
++    } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
++      # Override gcc encoded sysroot
++      push(@ccopt, $a);
+     } else {
+       die "$0: unknown option: $a\n";
+     }
meta-initramfs/recipes-devtools/klibc/klibc.inc +1 -0
index 0209b20..f3e9972 100644
@@ -16,6 +16,7 @@ SRC_URI_append_linux-uclibceabi = "
 file://klibc-config-eabi.patch \
                                     "
 SRC_URI += "file://klibc-linux-libc-dev.patch \
             file://staging.patch \
+            file://klcc-consider-sysroot.patch \
             "
 

S = "${WORKDIR}/git"
--
1.9.1

Quoted 6 lines

--
_______________________________________________
Openembedded-devel mailing list [email protected] <javascript:;>
http://lists.openembedded.org/mailman/listinfo/openembedded-devel

--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel