Hey Han,
thanks for the information. The cross-compiler I'm using is from
Toradex for the Apalis iMX6 [1] (it's for the iseg CC24, I'm not
sure if it is the default toolchain, or a customized version from
iseg)
Andrew already helped me fixing the problem. In
EPICS_BASE/configure/os/CONFIG_SITE.linux-86_64.linux-arm I
defined
> ARCH_DEP_CFLAGS += -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
> ARCH_DEP_LDFLAGS += --sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
I needed to extend ARCH_DEP_LDFLAGS by '-march=armv7-a -mthumb
-mfpu=neon -mfloat-abi=hard'.
With this change the correct interpreter is used and the IOC is
working without any workarounds!
Cheers,
Florian
[1]
https://developer.toradex.com/getting-started/module-2-my-first-hello-world-in-c/configure-toolchain-apalis-imx6
Am 01.09.2019 um 00:31 schrieb Jeong
Han Lee:
Hi
Florian,
If your cross-complier is based on the Yocto project, please
look at three configuration files in [1]. Especially,
linux-corei7-poky one may contains more explanation how the cc
configuration shell script can be converted into the EPICS base
configuration file. If you need more help, I may look at my
personal log how to do this later.
You may need the similar your own configuration file instead of
the standard EPICS base ones.
You have to create your own configuration in order to override
* GNU_DIR
* GNU_BIN
* GNU_TARGET_LIB_DIR
I don't have time to submit them to the community, at the same
time, they contains the site specific environment variables also.
HTH,
Han
[1] https://github.com/icshwi/e3-base/tree/master/configure/os
https://github.com/icshwi/e3-base/blob/master/configure/os/CONFIG_SITE.Common.linux-ppc64e6500
On 8/30/19 1:17 PM, Florian Feldbauer via Tech-talk wrote:
Hey,
I have another problem with cross-compiling.
When compiling a hello world program with my cross-toolchain and
inspecting it with `file`, the interpreter is
/lib/ld-linux-armhf.so.3.
When cross-compiling EPICS and inspecting the executable of my
IOC, the interpreter is /lib/ld-linux.so.3.
Does anyone know how I could fix this issue? For now I use a
symlink on my target system as a workaround:
> ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
But it would of course be better if this workaround would not be
needed at all.
Another question: When deploying the IOC to my target system,
the path is not necessarily the same as the building path
anymore.
So, when I start my IOC, I get the following warning:
Warning: IOC is booting with TOP = "/opt/epics"
but was built with TOP =
"/home/florian/epics/iocs/test-ioc"
Is there anyway to get rid of this warning?
Best regards,
Florian
On 8/29/19 9:43 PM, Florian Feldbauer via Tech-talk wrote:
Hey Andrew,
just when your mail arrived, I was looking through the output
of make and found a line, where g++ was used for compiling
using the correct flags. Like you said...
I now replaced USR_CFLAGS by ARCH_DEP_CFLAGS and added
ARCH_DEP_LDFLAGS +=
--sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
Now it works! Thanks for your help!
Cheers,
Florian
On 8/29/19 9:23 PM, Johnson, Andrew N. via Tech-talk wrote:
Hi Florian,
On 8/29/19 1:33 PM, Florian Feldbauer via Tech-talk wrote:
My
configure/os/CONFIG_SITE.linux-x86-64.linux-arm looks like
this
GNU_TARGET =
arm-angstrom-linux-gnueabi
GNU_BIN =
/opt/cross-compiler/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi
COMMANDLINE_LIBRARY = READLINE_NCURSES
USR_CFLAGS += -march=armv7-a -mthumb -mfpu=neon
-mfloat-abi=hard
--sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
USR_CXXFLAGS += -march=armv7-a -mthumb -mfpu=neon
-mfloat-abi=hard
--sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
Looking at the compiler commands executed by make below,
only the USR_CFLAGS are used when compiling c files, but
the CXXFLAGS are ignored.
USR_CFLAGS is used when compiling .c files to .o
USR_CXXFLAGS is used when compling .cpp/.cxx/.cc flags to .o
USR_LDFLAGS is used when linking .o files together into
executables or libraries.
It's the latter (link) stage that is failing in your build.
Your first command is a compilation of a C file, which
succeeds:
/opt/iseg/cross-compiler/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-gcc
-D_GNU_SOURCE -D_DEFAULT_SOURCE -march=armv7-a
-mthumb -mfpu=neon -mfloat-abi=hard
--sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
-DUNIX -Dlinux -O3 -g -Wall -march=armv7-a
-mthumb -mfpu=neon -mfloat-abi=hard
--sysroot=/opt/iseg/cross-compiler/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi
-fPIC -I. -I../O.Common -I. -I../../src/osi/compiler/gcc
-I../../src/osi/compiler/default -I.
-I../../src/osi/os/Linux -I../../src/osi/os/posix
-I../../src/osi/os/default -I.. -I../../src/as
-I../../src/bucketLib -I../../src/calc
-I../../src/cvtFast -I../../src/cppStd
-I../../src/cxxTemplates -I../../src/dbmf
-I../../src/ellLib -I../../src/env -I../../src/error
-I../../src/fdmgr -I../../src/flex -I../../src/freeList
-I../../src/gpHash -I../../src/iocsh -I../../src/log
-I../../src/macLib -I../../src/misc -I../../src/osi
-I../../src/pool -I../../src/ring -I../../src/taskwd
-I../../src/timer -I../../src/yacc -I../../src/yacc
-I../../src/yajl -I/opt/epics/base/include/compiler/gcc
-I/opt/epics/base/include/os/Linux
-I/opt/epics/base/include
-I/opt/epics/base/include/compiler/gcc
-I/opt/epics/base/include/os/Linux
-I/opt/epics/base/include -c
../../src/yajl/yajl_parser.c
The next command is actually using g++ to link object files
into a library (libCom.so.3.17.5), it isn't actually
compiling anything, so it doesn't get given your
$(USR_CXXFLAGS):
/opt/iseg/cross-compiler/sysroots/x86_64-angstromsdk-linux/usr/bin/arm-angstrom-linux-gnueabi/arm-angstrom-linux-gnueabi-g++
-o libCom.so.3.17.5 -shared -fPIC
-L/opt/epics/base/lib/linux-arm
-Wl,-rpath,/opt/epics/base/lib/linux-arm -rdynamic
asLib.o asTrapWrite.o bucketLib.o postfix.o
calcPerform.o cvtFast.o resourceLib.o
epicsSingletonMutex.o dbmf.o ellLib.o ellSort.o
envSubr.o envData.o errlog.o errSymLib.o errSymTbl.o
fdmgr.o fdManager.o freeListLib.o gpHashLib.o iocsh.o
initHooks.o registry.o libComRegister.o iocLog.o
logClient.o macCore.o macEnv.o macUtil.o alarmString.o
aToIPAddr.o adjustment.o cantProceed.o epicsConvert.o
epicsExit.o epicsStdlib.o epicsString.o truncateFile.o
ipAddrToAsciiAsynchronous.o epicsUnitTest.o
epicsThread.o epicsMutex.o epicsEvent.o epicsTime.o
epicsMessageQueue.o epicsMath.o epicsAtomicOSD.o
epicsGeneralTime.o osiClockTime.o osdSock.o
osdSockAddrReuse.o osiSock.o systemCallIntMech.o
epicsSocketConvertErrnoToString.o osdAssert.o
osdFindSymbol.o osdInterrupt.o osdPoolStatus.o
osdSignal.o osdEnv.o epicsReadline.o epicsTempFile.o
epicsStdio.o osdStdio.o osdThread.o osdThreadExtra.o
osdThreadHooks.o osdMutex.o osdSpin.o osdEvent.o
osdTime.o osdMonotonic.o osdProcess.o osdNetIntf.o
osdMessageQueue.o devLibVME.o devLibVMEOSD.o
epicsStackTrace.o osdBackTrace.o osdFindAddr.o poolJob.o
threadPool.o epicsRingPointer.o epicsRingBytes.o
taskwd.o epicsTimer.o timer.o timerQueue.o
timerQueueActive.o timerQueueActiveMgr.o
timerQueuePassive.o yajl.o yajl_alloc.o yajl_buf.o
yajl_encode.o yajl_gen.o yajl_lex.o yajl_parser.o
-lpthread -lreadline -lncurses -lm -lrt -ldl -lgcc
The last command breaks because the --sysroot option is
missing and the compiler doesn't find it's libraries.
Did I do something wrong? What is the correct way to
define default C compiler and C++ compiler flags when
cross-compiling?
You didn't set a variable to provide the linker flags needed
for your build. Following your other settings that would be
USR_LDFLAGS, but I would recommend that you actually set
these variables instead:
ARCH_DEP_CFLAGS = <your USR_CFLAGS value above>
The ARCH_DEP_CXXFLAGS variable defaults to
$(ARCH_DEP_CFLAGS) so you don't need to set this at all.
ARCH_DEP_LDFLAGS = <flags to pass to g++ when using it as
a linker>
I'm suggesting you use the ARCH_DEP_ flags instead of the
USR_ ones because some application Makefiles may override
the USR_ variables instead of just appending to them, which
would cause your builds to fail.
Hope this helps,
- Andrew
--
Complexity comes for free, Simplicity you have to work for.
--
Dr. Florian Feldbauer
Ruhr-Universität Bochum
Experimentalphysik I AG
Universitätsstr. 150
Fach-Nr. 125
D-44801 Bochum
Office: NB 2/134
Phone: (+49)234 / 32-23563
Fax: (+49)234 / 32-14170
https://paluma.ruhr-uni-bochum.de
|