0

Could you help me to undrestand the following points:

1- How the following line env="HOSTARCH'from the root Config.in of buildroot is interpreted:

config BR2_HOSTARCH
string
option env="HOSTARCH"

2- The value of BR2_HOSTARCH from the graphical view after a make menuconfig is x86_64, how does it get assigned ?

3- Why when I grep BR2_HOSTARCH in the .config I can't find it?

StevenWhite
  • 5,907
  • 3
  • 21
  • 46
Mouin
  • 1,025
  • 4
  • 19
  • 33

1 Answers1

2

Did you look at the git history? E.G. git blame Config.in and then the commit adding the lines above?

It is imho quite clear what it does, how and why from the commit description: https://git.buildroot.org/buildroot/commit/?id=1d4104f0d0428297a8b447a0e08c81a9eaee7f62

commit 1d4104f0d0428297a8b447a0e08c81a9eaee7f62
Author: Francois Perrad <fperrad@gmail.com>
Date:   Wed Jul 18 15:59:09 2012 +0200

    add host arch detection and Kconfig BR2_HOSTARCH

    This will allow to install binary package only if they are supported by the
    host. As example Atmel SAM-BA (x86 only).

    Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
    Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

diff --git a/Config.in b/Config.in
index 925c2474c..c182f7044 100644
--- a/Config.in
+++ b/Config.in
@@ -10,6 +10,10 @@ config BR2_VERSION
        string
        option env="BR2_VERSION_FULL"

+config BR2_HOSTARCH
+       string
+       option env="HOSTARCH"
+
 source "target/Config.in.arch"

 menu "Build options"
diff --git a/Makefile b/Makefile
index d55b136a8..639fdaa1f 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,16 @@ ifneq ($(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSI
 $(error You have make '$(MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
 endif

+export HOSTARCH := $(shell uname -m | \
+       sed -e s/i.86/x86/ \
+           -e s/sun4u/sparc64/ \
+           -e s/arm.*/arm/ \
+           -e s/sa110/arm/ \
+           -e s/ppc64/powerpc/ \
+           -e s/ppc/powerpc/ \
+           -e s/macppc/powerpc/\
+           -e s/sh.*/sh/)
+
 # This top-level Makefile can *not* be executed in parallel
 .NOTPARALLEL:

E.G. it is the output of uname -m with a bit of post processing, which gets forwarded to Kconfig through the environment. It isn't stored in .config as it is a "blind" option, E.G. without a prompt.

Is that any specific reason why you ask this?

Peter Korsgaard
  • 626
  • 4
  • 3
  • OK get it thanks, i didn't know that "env=" imports the environement variable. Actually i'am working on [this bug] (http://autobuild.buildroot.net/results/523/523bfd527a939bfa2bc8610dc3b3f20cddbd72a5/), i have a 64 bit machine but i find that with this config the binaries generated on `/output/host/opt/ext-toolchain` are for 32 bits machine. any hints to resolve this probem is appreciated. – Mouin Jan 21 '17 at 11:58
  • The kconfig language is documented in the Linux kernel documentation (as that is where it comes from): https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Regarding the autobuilder issue, output/host/opt/ext-toolchain is where a downloadable external toolchain gets extracted, and the used toolchain is a 32bit toolchain, so that explains the 32bit binaries – Peter Korsgaard Jan 22 '17 at 17:34
  • Thx you mean http://autobuild.buildroot.org/toolchains/tarballs/armv5-ctng-linux-gnueabi.tar.xz. points to a 32bit toolchain ? , how can i distinguish between a 32bit and 64bits toolchain from the name ?, do you think that it's useless to add a check for the downloaded toolchain? – Mouin Jan 24 '17 at 20:30
  • Yes it is: file armv5-ctng-linux-gnueabi/bin/armv5-ctng-linux-gnueabi-gcc armv5-ctng-linux-gnueabi/bin/armv5-ctng-linux-gnueabi-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=454f7be59528a5f60bd9f6d973202e673b6b3f97, stripped – Peter Korsgaard Jan 25 '17 at 21:18
  • Is there any specific reason why you are so interested in knowing if the toolchain is 32bit or 64bit? – Peter Korsgaard Jan 25 '17 at 21:20
  • Thanks, No just curiosity, I was just asking if it's possible to know if the toolchain is 32bits or 64bits before downloading. in your comment above i have to download extract then use `file` command. – Mouin Jan 26 '17 at 13:06