buildroot environment with host toolchain - buildroot

For running testcases etc. I would like to compile parts of our buildroot environment for the Host system (/usr/bin/gcc etc.).
I tried specifying an external_toolchain in /usr but this fails. Has anyone managed to do something like this?
The buildroot manual says this is unsupported because they can not import it into a rootfs. But for testcases a rootfs is not necessary.

Yeah, unfortunately, it is not possible to do this. To be useful for Buildroot, a toolchain has to be a "pure" toolchain, i.e containing only the C library binaries and headers. You /usr is cluttered with gazillions of libraries from your host machine, and since Buildroot makes a full copy of the toolchain sysroot (which in your case, would be /usr), it would copy many, many things.
So definitely, it is not something that we support, and we don't intend to support this. You can also decide to build your programs with a x86 or x86_64 cross-compiler, have Buildroot generate a minimal Linux system, and chroot into it directly on your development PC.

The current documentation also seems to explain that this is not possible https://github.com/buildroot/buildroot/blob/2018.08/docs/manual/configure.txt#L198
We also do not support using the distribution toolchain (i.e. the
gcc/binutils/C library installed by your distribution) as the
toolchain to build software for the target. This is because your
distribution toolchain is not a "pure" toolchain (i.e. only with the
C/C++ library), so we cannot import it properly into the Buildroot
build environment. So even if you are building a system for a x86 or
x86_64 target, you have to generate a cross-compilation toolchain with
Buildroot or crosstool-NG.
Furthermore, current Buildroot seems to check if your toolchain path seems to be a global toolchain, and bails out automatically if it is https://github.com/buildroot/buildroot/blob/2018.08/toolchain/helpers.mk#L395
with_sysroot=`$${__CROSS_CC} -v 2>&1 |sed -r -e '/.* --with-sysroot=([^[:space:]]+)[[:space:]].*/!d; s//\1/'`; \
if test "$${with_sysroot}" = "/" ; then \
echo "Distribution toolchains are unsuitable for use by Buildroot," ; \
echo "as they were configured in a way that makes them non-relocatable,"; \
echo "and contain a lot of pre-built libraries that would conflict with"; \
echo "the ones Buildroot wants to build."; \
exit 1; \
fi; \

Related

Showing a list of software with LGPL during boot

I remember seeing a list of software components with LGPL licenses during the start up of Linux root file system built with Yocto Project. I can't seem to figure out what enables this, even after going through the Mega Manual.
NOTICE: This file system contains the following GPLv3 packages:
autoconf
bash-dev
bash
binutils
cifs-utils
cpio
cpp-symlinks
cpp
dosfstools
elfutils
g++-symlinks
g++
gawk-dev
gawk
gcc-symlinks
gcc
gdb
gdbc6x
gdbserver
gettext-dev
gettext
gzip
libbfd
libcairo-dbg
libcairo-perf-utils
libdw1
libelf1
libgdbm-compat4
libgdbm-dev
libgdbm4
libgettextlib
libgettextsrc
libgmp-dev
libgmp10
libgmpxx4
libidn11
libmpc3
libmpfr4
libreadline-dev
libreadline7
libunistring2
m4-dev
m4
make
nettle-dev
nettle
parted
python3-pycairo-dev
python3-pycairo
which
If you do not wish to distribute GPLv3 components please remove
the above packages prior to distribution. This can be done using
the opkg remove command. i.e.:
opkg remove <package>
Where <package> is the name printed in the list above
NOTE: If the package is a dependency of another package you
will be notified of the dependent packages. You should
use the --force-removal-of-dependent-packages option to
also remove the dependent packages as well
Found my answer - it's from arago-gpl-notice from meta-arago. It only displays GPLv3 also.

How can I get Ada GNAT gcc 7.3 for Solaris 11?

We have a Solaris 11 system with gcc 7.3, we need to install the Ada package. On Linux gcc 7 came with the Ada/GNAT as part of the gcc install:
apt install gcc
I visited AdaCore looks like Solaris (SPARC) is not longer on the list. I need to use Ada95 and we want the same compiler on both Linux and Solaris in any case.
pkg install gcc
Only installed various C++ commands and Fortran.
pkg install gcc-ada
And variants like gcc7ada, found nothing to install.
If must, we can rebuild the Ada component of GCC 7, however I haven't found a clear cood-book style "How To ..."for that (yet).
Hopefully you can point me to these items in order of preference to help us get back-on-track.
Solaris 11 gcc-ada package for gcc7/Solaris 11 spark, and the package repository.
An 'alternative' package repository were I can retrieve the GCC Ada tooling.
Pre-build GCC 7 Ada module that we can copy to the right places.
Ready-rolled Build Ada/GNAT project for Solaris and how to download and get start building.
Instructions to download and build gcc-ada with gcc 7 on Solaris (or Unix).
From th epast few days searching about on Gnu Compiler Collection, Oracle, the package manager searches, google and so forth ... It really seems like there's next to no support for CGG Ada on Solaris these days.
I very interested in other solutions beyond that list. For instance, has anyone cross-compiled from Linux to Solaris? Would that work with GDB on the Solaris machine anyway?
Looking forward to your suggestions.
I've successfully built gcc 7.50 (x86_64 native with i386 cross-compiler) with GNAT on OpenIndiana (Hipster 2020/10) using the following procedure.
Download the bootstrap compiler from Dragonlace at http://downloads.dragonlace.net/src/ada-bootstrap.x86_64.solaris.511.tar.bz2
Get the illumos gcc 7.5.0 source from https://github.com/illumos/gcc/tree/il-7_5_0
Put the bootstrap compiler's bin directory at the front of $PATH, replace /usr/bin/gcc /usr/bin/cpp /usr/bin/g++ with symlinks to their counterparts in the bootstrap compiler directory (see note below re g++ and c++)
Make sure you've got gnu-binutils and gmake; then run contrib/download_prerequisites
Configure with
--enable-languages='c ada c++' --build=x86_64-aux-solaris2.11 --enable-threads=posix --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-nls --disable-shared --disable-lto --disable-libstdcxx-pch --enable-multilib --with-gnu-as --with-as=/usr/bin/gas --without-gnu-ld --with-ld=/usr/bin/ld
gmake and then gmake install
NOTES:
This setup should be close enough to Solaris 11 to work. If it doesn't, try using the regular gcc 7.5.0 release rather than the illumos-modified branch.
If you get stuck at a linking stage, try using a gcc ld, but you should definitely try to use the Solaris ld first. The gnu as (gas) makes the build go much more smoothly. I didn't have any problems, but if you get stuck at the end of stage 1 or the beginning of stage 2, try setting $CONFIG_SHELL=/usr/bin/ksh -- I think it has been fixed, but at least with older gcc releases one needed to specify ksh because the built-in sh had some non-POSIX peculiarities that didn't work with some of the components' makefiles
I couldn't get one of the support libs for gnat to compile easily without building gcc c++ and using g++ with a full bootstrap. You might be able to figure it out, but the path of least resistance is likely to build gcc c++ and put the g++ symlink in /usr/bin, which is where the makefile wanted to find it.
Please note that I don't know much about Solaris, but a quick search on Google gave me the website OpenCSW. This website provides the packages gcc4ada and gcc5ada.
It appears that gcc5ada is build using a makefile (as found here, in particular notice line 424). A similar makefile exists for gcc7ada (as found here, in particular notice line 426). However, while it seems that the package "gcc7ada" can be created with the latter makefile, it is not published on the OpenCSW.org website (website is no longer updated?).
You could try to install gcc5ada first and then use this old GCC/GNAT compiler as a bootstrapper for compiling the required version (using the GCC 7 makefile).

Building only gcc using yocto

I was trying to build only gcc using yocto. I tried with "bitbake-layers show-recipes" it was showing multiple recipes for gcc, similarly for bitbake -s.
#bitbake-layers show-recipes
gcc:
meta 4.8.2
gcc-cross:
meta 4.8.2
gcc-cross-canadian-arm:
meta 4.8.2
gcc-cross-initial:
meta 4.8.2
gcc-crosssdk:
meta 4.8.2
gcc-crosssdk-initial:
meta 4.8.2
gcc-runtime:
meta 4.8.2
gccmakedep:
meta 1:1.0.2
#bitbake -s
gcc :4.8.2-r0
gcc-cross :4.8.2-r0
gcc-cross-canadian-arm :4.8.2-r0
gcc-cross-initial :4.8.2-r0
gcc-crosssdk :4.8.2-r0
gcc-crosssdk-initial :4.8.2-r0
gcc-runtime :4.8.2-r0
gccmakedep 1:1.0.2-r3
Please guide me to understand why there are multiple recipes related to gcc and which one I have to build.
In yocto, is there one to one match for recipe and package. i.e for creating each package there is a corresponding only one recipe?
To explain each one in turn:
gcc is the recipe for gcc that runs on the target machine itself.
gcc-cross is the cross-compiler that the build system uses. If you build any recipe for the target that needs to be compiled with gcc, this is what will be used to compile that.
gcc-cross-canadian- is the final relocatable cross-compiler for the SDK, in this case for the ARM architecture.
gcc-crosssdk is an intermediate step in producing gcc-cross-canadian.
the *-initial are the initial versions of the compiler required to bootstrap the toolchain separately for the standard cross-compiler and for the SDK.
gcc-runtime builds the runtime components that come as part of gcc (e.g. libstdc++).
gccmakedep isn't really part of gcc itself, it's a script that comes as part of the X11 utilities that some projects need to determine dependencies for each source file.
When you say "you only need to build gcc", it's not entirely clear what you mean, but I suspect it's either gcc for the target (in which case it's "gcc", though I suspect you'll probably need more than that - packagegroup-core-buildessential may be what you want) or you want a cross-compiler you can install separately in which case you probably ought to bitbake meta-toolchain or bitbake -c populate_sdk imagename. That'll contain more than just gcc but it's likely gcc alone isn't going to be enough anyway.
GCC is a huge project. Maybe this recipe could help you understand GCC and Yocto a little bit better. The following information is some information paraphrase from "Embedded Linux Projects Using Yocto Project Cookbook" by Alex Gonzalez
GNU toolchain contains the following components:
Assembler (GNU as): part of the binutils package
Linker (GNU Id):
part of the binutils package
Compiler (GNU gcc): support for C, C++,
Java, Ada, Fortran, and Objective C
Debugger (GNU gdb): GNU debugger
Binary file tools (objdump, nm, objcopy, readelf, strip, and so on):
these are part of the binutils package
These components are enough to build bare metal applications
bootloaders like u-boot, Linux Kernel because they do not need C
library and they implement C library functions they need.
POSIX-compliant C library is needed for LInux user space applications.
glibc is the default C library used in the Yocto Project.
On Embedded Systems, we need a cross-compilation toolchain. We build
in a host computer but run the result binarines on the target which is
usually different architecture. There are several types of toolchains
based on build machine, target machine.
The most common combinations are:
Native: An example of this is an x86 machine running a toolchain that >has also been built on an x86 machine
producing binaries to run on an x86 machine. This is common in desktop
computers.
Cross-compilation: This is the most common on embedded
systems; for example, an x86 machine running a toolchain that has also
been built on an x86 machine but producing binaries to run on a
different architecture, like ARM.
Cross-native: This is typically the
toolchain running on targets. An example of this is where a toolchain
has been built on an x86 machine but runs on ARM and produces
Canadian: Rarely seen, this is where the build, host, and target
machines are all different.

How to use jpeglib in xCode

I'm developing an iPhone application and I'm kind of new to everything. I'm working on Mountain Lion OS X 10.8 and using xCode v4.5. I need JPEG handling capabilities in my project and I want to use the libjpeg (http://www.ijg.org/) library. I have tried a few different approaches, but being a bit naive, I'm not really sure how to begin. After downloading packages I've made usual ./configure; make and make install. Right now I have (jconfig.h, jerror.h, jmorecfg.h, jpeglib.h) under (/usr/local/include) and (libjpeg.a, libjpeg.la) under (/usr/local/lib) but I have no idea how to link/use this in my xCode project.
Can anyone link me to a tutorial or give me a push in the right direction?
If anyone successfully installed and used jpeg library please help..
This is a bit of a pain, because you will need to compile LibJPEG for two architectures: ARM, for iOS, and x86, for the simulator.
Your best bet is to use NSImage or CGImage. There already is a JPEG library on iOS, supplied with the system, so you don't need to use LibJPEG.
An alternative is to put the LibJPEG sources directly into your project (including the *.c files). This way, they will be built correctly for different architectures (simulation and deployment).
You could also just build for ARM, and then forget about running the simulator.
Or you could build LibJPEG as a fat binary by compiling it twice and combining the resulting library (libjpeg.a) from each compilation with libtool.
libtool -static path/to/arm/libjpeg.a path/to/x86/libjpeg.a -o libjpeg.a
You can see why the recommendation is to use NSImage or CGImage. Better to use a library that is already installed rather than try to build and install a new one.
How to make a fat static library
Since it sounds like you want to do things the hard way, here is an example of how to build a fat static library for i386 and ppc architectures. This was done on a PowerPC OS X box, you will have to adjust if you want to compile for ARM and i386.
Note that you have to specify --host and --build for cross-compiling. The values below are correct for my computer, but I am certain that they are wrong for your computer.
$ cd jpeg-8d
$ mkdir build-ppc build-i386
$ cd build-ppc
$ ../configure CFLAGS='-arch ppc -O2 -g' LDFLAGS='-arch ppc' \
--enable-static --disable-shared
$ make -j2
$ cd ../build-i386
$ ../configure CFLAGS='-arch i386 -O2 -g' LDFLAGS='-arch i386' \
--enable-static --disable-shared \
--build=powerpc-apple-darwin9.8.0 --host=i386-apple-darwin9.8.0
$ make -j2
$ cd ..
$ file build-ppc/.libs/libjpeg.a
build-ppc/.libs/libjpeg.a: current ar archive random library
$ file build-i386/.libs/libjpeg.a
build-i386/.libs/libjpeg.a: current ar archive random library
$ libtool -static build-*/.libs/libjpeg.a -o libjpeg.a
$ file libjpeg.a
libjpeg.a: Mach-O universal binary with 2 architectures
libjpeg.a (for architecture i386): current ar archive random library
libjpeg.a (for architecture ppc): current ar archive random library

how to build PoDoFo library for iOS

This may be a copy of this question How can I use the PoDoFo library for annotating PDFs on iOS? not responded yet.
i know how to use/create static libraries into xcode projects for iOS. i was looking for a free PDF library which support in memory editing of pdf documents and i came to know that PoDoFo done it very well, i tried to build this library for xcode but i really don't know how to play with CMake. can any body tell me how can i use this library into my iOS application.
thanks
This is an extract from Podofo 'Read me' file
CMake builds on Mac OS X
Mac OS X users can build PoDoFo using CMake either by generating conventional UNIX Makefiles (the "Unix Makefiles" CMake target) or generating an XCode project (the "Xcode" target). In either case the following applies.
You will need freetype and fontconfig. It's possible to omit the use of libjpeg (see the platform-independent documentation) but by default libjpeg will also be required. If you have these libraries already (say, from fink or DarwinPorts) you can skip the following section and update the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH arguments appropriately.
Dependencies
I'll assume you're installing podofo and any required libraries into $HOME/libs . Adjust to taste, but keep it consistent.
The easiest way to get any required libraries is to use MacPorts to install the libjpeg, fontconfig, and freetype libraries. Once you've installed MacPorts, just run:
/opt/local/bin/port install fontconfig freetype jpeg tiff lua
MacPorts will automatically build the libraries and their dependencies, installing them in /opt/local.
If you want to distribute the libraries with your application, all you'll need to do is use install_name_tool to set appropriate relative paths for their linkage and include them in your application bundle - just like you do with any other libraries.
PoDoFo itself
You should be able to configure and install podofo on Mac OS X using:
cmake -G "Unix Makefiles" \
-DWANT_FONTCONFIG:BOOL=TRUE \
-DCMAKE_INSTALL_PREFIX=/opt/podofo \
-DCMAKE_INCLUDE_PATH=/opt/local/include \
-DCMAKE_LIBRARY_PATH=/opt/local/lib \
../podofo
make
sudo mkdir /opt/podofo
sudo chown $USER /opt/podofo
make install
change "Unix Makefiles" to "Xcode" if you want to build an XCode project instead, then instead of running make' andmake install' just open the project file and work as normal
Instead of using 'XCode' in the command, type 'Xcode', (c lowercase) and it should do the trick.