Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on Arm #613

Closed
bioinfornatics opened this issue May 19, 2014 · 27 comments
Closed

Compiling on Arm #613

bioinfornatics opened this issue May 19, 2014 · 27 comments
Labels

Comments

@bioinfornatics
Copy link
Contributor

Dear,
build issue with arm

/builddir/build/BUILD/ldc-0.13.0-beta1-src/runtime/druntime/src/core/sys/posix/sys/stat.d(375): Error: static assert  (96u == 104u) is false
make[2]: *** [runtime/src/core/sys/posix/sys/stat-debug.o] Error 1

complete build log: http://kojipkgs.fedoraproject.org//work/tasks/4898/6864898/build.log

@redstar
Copy link
Member

redstar commented May 20, 2014

Hi,
this surprises me a bit. At least cross-compiling on Windows, I get the same error (-mtriple=armv7-linux-gnuehabi). I need to check it on my ARM box, too. I am sure that this used to compile.

@bioinfornatics
Copy link
Contributor Author

Hi redstar,

Did you have find where is problem come from ?

@redstar
Copy link
Member

redstar commented Jun 27, 2014

No. I see the failure if I cross-compile from x86. There is no failure on my native ARM box. The unit test builds and runs (almost):

185/1116 Test #185: druntime_src_core_sys_posix_sys_stat_debug_build .........   Passed    3.23 sec
        Start 186: druntime_src_core_sys_posix_sys_stat_debug_run
186/1116 Test #186: druntime_src_core_sys_posix_sys_stat_debug_run ...........***Exception: SegFault  0.02 sec
        Start 187: druntime_src_core_sys_posix_sys_stat_release_build
187/1116 Test #187: druntime_src_core_sys_posix_sys_stat_release_build .......   Passed    4.53 sec
        Start 188: druntime_src_core_sys_posix_sys_stat_release_run
188/1116 Test #188: druntime_src_core_sys_posix_sys_stat_release_run .........   Passed    0.02 sec

@redstar
Copy link
Member

redstar commented Jun 30, 2014

Ok, I rechecked this. Native compilation works, cross compilation does not work (see issue #259 and pull request #643).
Is this a cross compile?

@redstar
Copy link
Member

redstar commented Jul 19, 2014

It depends on the used target triple. armv7a-unknown-linux-gnueabihf works but armv7-unknown-linux-gnuehabi does not. Needs further investigations.

@bioinfornatics
Copy link
Contributor Author

OK thanks @redstar

@bioinfornatics
Copy link
Contributor Author

little update.
LDC fail always to build on arm. A piece of build log

[ 27%] Generating src/core/sys/posix/sys/stat.o
cd /builddir/build/BUILD/ldc-0.15.1-src && /builddir/build/BUILD/ldc-0.15.1-src/build/bin/ldc2 --output-o -c -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/gc /builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/core/sys/posix/sys/stat.d -of/builddir/build/BUILD/ldc-0.15.1-src/build/runtime/src/core/sys/posix/sys/stat.o -w -d -relocation-model=pic -O3 -release -disable-invariants -d-version=Shared
/usr/bin/cmake -E cmake_progress_report /builddir/build/BUILD/ldc-0.15.1-src/build/CMakeFiles 
/usr/bin/cmake -E cmake_progress_report /builddir/build/BUILD/ldc-0.15.1-src/build/CMakeFiles 
[ 27%] /usr/bin/cmake -E cmake_progress_report /builddir/build/BUILD/ldc-0.15.1-src/build/CMakeFiles 
[ 27%] Generating src/core/sys/posix/sys/wait.o
cd /builddir/build/BUILD/ldc-0.15.1-src && /builddir/build/BUILD/ldc-0.15.1-src/build/bin/ldc2 --output-o -c -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/gc /builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/core/sys/posix/sys/wait.d -of/builddir/build/BUILD/ldc-0.15.1-src/build/runtime/src/core/sys/posix/sys/wait.o -w -d -relocation-model=pic -O3 -release -disable-invariants -d-version=Shared
[ 27%] Generating src/core/sys/posix/sys/socket.o
cd /builddir/build/BUILD/ldc-0.15.1-src && /builddir/build/BUILD/ldc-0.15.1-src/build/bin/ldc2 --output-o -c -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src -I/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/gc /builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/core/sys/posix/sys/socket.d -of/builddir/build/BUILD/ldc-0.15.1-src/build/runtime/src/core/sys/posix/sys/socket.o -w -d -relocation-model=pic -O3 -release -disable-invariants -d-version=Shared
/builddir/build/BUILD/ldc-0.15.1-src/runtime/druntime/src/core/sys/posix/sys/stat.d(440): Error: static assert  (96u == 104u) is false
runtime/CMakeFiles/druntime-ldc.dir/build.make:355: recipe for target 'runtime/src/core/sys/posix/sys/stat.o' failed
make[2]: *** [runtime/src/core/sys/posix/sys/stat.o] Error 1

full log

Fedora use these switch to build on arm:

-march=armv7-a -mfpu=vfpv3-d16  -mfloat-abi=hard

I hope that will help you

@bioinfornatics
Copy link
Contributor Author

Does the new beta release fix it ?

@redstar
Copy link
Member

redstar commented Mar 21, 2015

I can't check because my ARM device is currently not usable.

@denizzzka
Copy link
Contributor

Same error

$ ldc2 -march=thumb -mcpu=cortex-m3 -c -g start.d
/usr/include/d/core/sys/posix/sys/stat.d(440): Error: static assert  (96u == 104u) is false

if I am trying to add "import dopencm3.gpio;" into start.d:

But it is work fine if

$ ldc2 -c -g start.d

is used or if "import dopencm3.gpio;" is commented out

@bioinfornatics
Copy link
Contributor Author

update still failling with the alpha3 release 8956066
ldc_build

/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
In file included from /builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asmstmt.cpp:113:0:
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
     };
     ^
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
/builddir/build/BUILD/ldc-0.16.0-alpha3-src/gen/asm-x86.h:225:5: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]
CMakeFiles/LDCShared.dir/build.make:2524: recipe for target 'CMakeFiles/LDCShared.dir/gen/asmstmt.cpp.o' failed

full log

@redstar
Copy link
Member

redstar commented Sep 18, 2015

The error occurs because char is unsigned char on ARM and signed char on x86 and GCC 5.x now makes the narrowing conversion an error. I'll try to fix this but you could also try to add -DEXTRA_CXXFLAGS=-fsigned-char to the cmake call.

@redstar
Copy link
Member

redstar commented Sep 18, 2015

Fixed in master.

@cottsay
Copy link

cottsay commented Dec 14, 2015

I just tested 0.16.1. With or without -DEXTRA_CXXFLAGS=-fsigned-char, the narrowing conversion errors are gone.

Unfortunately, with or without -DEXTRA_CXXFLAGS=-fsigned-char, I still see Error: static assert (96u == 104u) is false.

@redstar, what is the reason behind -DEXTRA_CXXFLAGS=-fsigned-char? Should it be set only on ARM builds or all arches?

--scott

@joakim-noah
Copy link
Contributor

This works now, right? @smolt, want to close this too?

@smolt
Copy link
Member

smolt commented Mar 25, 2016

I think this may still be a problem. Last time I tried to cross-compile to arm-linux-gnueabihf, I got similar static assert error listed above. That was a month ago.

@cottsay
Copy link

cottsay commented Apr 17, 2016

Still seeing the same static assert on Fedora in 0.17.1:

[ 18%] Generating src/core/sys/posix/sys/stat.o
cd /home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src && /home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/build/bin/ldc2 --output-o -c -I/home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/runtime/druntime/src -I/home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/runtime/druntime/src/gc /home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/runtime/druntime/src/core/sys/posix/sys/stat.d -of/home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/build/runtime/src/core/sys/posix/sys/stat.o -w -d -relocation-model=pic -O3 -release -disable-invariants -d-version=Shared
/home/mockbuild/rpmbuild/BUILD/ldc-0.17.1-src/runtime/druntime/src/core/sys/posix/sys/stat.d(438): Error: static assert  (96u == 104u) is false

I do see -fsigned-char during compilation in earlier lines.

@smolt
Copy link
Member

smolt commented Apr 17, 2016

This is happening when ARM ABI selected by target triple is older APCS. For example, I see in LLVM source that:

arm-linux-gnueabi is AAPCS
arm-linux-gnu is APCS

AAPCS aligns 64-bit ints to 64-bits, APCS does not. This results in struct stat_t having different sizes due to ABI.

This should be ok, but then there is that pesky static assert to check size in stat.d that assumes AAPCS. Is the assert needed? Maybe the fix is to just delete the static assert because I am guessing it was just a sanity check against the C sizeof(struct stat) when it was ported.

@smolt
Copy link
Member

smolt commented Apr 18, 2016

@redstar thoughts?

@redstar
Copy link
Member

redstar commented Apr 19, 2016

@smolt I would prefer not to loose the static assert. It is really helpful for porting.

@smolt
Copy link
Member

smolt commented Apr 19, 2016

Ok, then something like this would work:

static if(__USE_FILE_OFFSET64)
    static assert(stat_t.sizeof == (long.alignof==8 ? 104:96));
else
    static assert(stat_t.sizeof == (long.alignof==8 ? 88:TBD));

@redstar
Copy link
Member

redstar commented Apr 19, 2016

Yes, LGTM.

@smolt
Copy link
Member

smolt commented May 10, 2016

Coming back to this - I could not find a Linux that is APCS (arm-linux-gnu) as opposed to modern AAPCS (arm-linux-gnueabi)? Does anybody have such an environment? References show Fedora as gnueabi (original OS mentioned in this Issue). I noticed that LLVM does a simple string match to identify Linux environment so anything that begins as "gnu" but doesn't begin with "gnueabi" is considered non-EABI, that is APCS. Could all the reported errors here be type-ohs? My cross-compile case was a type-oh. Look above and also see another one -mtriple=armv7-linux-gnuehabi.

However, if APCS is really out there and needed, we could change stat.d assertion, but there must be more APCS incompatibilities, especially varargs and exception handling. Where can it be tested?

@cottsay
Copy link

cottsay commented May 11, 2016

I see two prefixes available in Fedora:

  • arm-none-eabi-
  • armv7hl-redhat-linux-gnueabi-

The latter is the system-wide default. Is that helpful?

@smolt
Copy link
Member

smolt commented May 11, 2016

@cottsay - thank. You are getting the stat.d assertion with a triple ending in gnueabi? as far as I can tell, that shouldn't be. What does your ldc2 -version spit out? I am curious what default target is. Did you configure and build your own llvm?

@joakim-noah
Copy link
Contributor

I've been both cross-compiling for and building on Android/ARM for a couple years now. This issue hasn't been updated in a year and a half, should it be closed?

@kinke
Copy link
Member

kinke commented May 12, 2018

I've never run into this with Debian 8 and armv6-linux-gnueabihf either and there have been no more reports of this kind, so closing.

@kinke kinke closed this as completed May 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants