Hi there,
I am trying to cross-compile a project using Gradle (for a specific processor), and I am having some issues. When I cross-compile my project using a command line, everything works fine. My first task:
task CheckCmd(type:Exec) {
commandLine '56400-gcc', '--version'
}
gives the following result:
56400-elf-gcc (GCC) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
My second task
task CompileCmd(type:Exec) {
commandLine '56400-gcc', '-x', 'c', '-c', '-I/home/nicolas06/experiment/Gradle/MyProject/src/main/headers', '-Wall', '-Werror', '-mos=nodeos', '/home/nicolas06/experiment/Gradle/MyProject/src/main/c/cluster_main.c'
}
compiles the C code without warning or error.
Now, when I try to do the same automatically with Gradle, it does not work.
allprojects {
apply plugin : 'c'
model {
toolChains {
arch56400_toolchain(Gcc) {
target("arch56400"){
cCompiler.executable '56400-gcc'
cCompiler.withArguments { List<String> args ->
args << '-Wall'
args << '-Werror'
args << '-mos=nodeos'
}
assembler.executable '56400-gcc'
linker.executable '56400-gcc'
}
}
}
platforms {
arch56400 {
architecture "arch56400"
}
}
components {
main(NativeExecutableSpec) {
targetPlatform "arch56400"
}
}
}
Executing gradle mainExecutable
gives the following result:
$ gradle mainExecutable
> Task :compileMainExecutableMainC FAILED
/home/nicolas06/Documents/Gradle/kalray_again/src/main/c/cluster_main.c: In function ‘main’:
/home/nicolas06/Documents/Gradle/kalray_again/src/main/c/cluster_main.c:35:4: error: implicit declaration of function ‘pthread_attr_setaffinity_np’ [-Werror=implicit-function-declaration]
It’s a compilation error that I get with gradle mainExecutable
but not with the commandLine
. To be more specific, the flag -mos=nodeos
that is specific to the cross-compiler 56400-gcc
is not processed correctly and it generates a compilation issue. If I remove that flag from my CompileCmd
task, I get the same compilation error.
Nota. The error is created by th following code code in a header (thread.h):
#if defined(__nodeos__)
int _EXFUN(pthread_attr_setaffinity_np,
(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset));
#endif
The if defined(__nodeos__)
is true when running the commandLine
but not when running the mainExecutable
. So, It seems to me that the flag args << '-mos=nodeos'
is deleted? removed? set aside? by Gradle when I run a cross-compilation and I don’t understand why. Can anyone help me solve that problem?
Thanks!