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

Standalone toolchain for mips is missing a system include dir on ndk r14 #310

Closed
N-Bz opened this issue Mar 3, 2017 · 6 comments
Closed
Assignees
Milestone

Comments

@N-Bz
Copy link

N-Bz commented Mar 3, 2017

Description

Standalone mips 32bits c++ toolchains are missing a system include dir.

Compiling this simple c++ program with standalone mips toolchain with ndk-r14 fails:

#include <bits/c++config.h>

int main() {
    return 0;
}

Toolchains were generated with the following command lines:

  • ./build/tools/make-standalone-toolchain.sh --arch=mips64 --install-dir=/tmp/toolchain_mips64/ --platform=android-21 for the mips64 toolchain (working reference)
  • ./build/tools/make-standalone-toolchain.sh --arch=mips --install-dir=/tmp/toolchain_mips/ --platform=android-21 for the mips32 toolchain (with the build issue)

Program was built with the following command line:

  • /tmp/toolchain_mips64/bin/mips64el-linux-android-clang++ /tmp/test.cpp -o /tmp/64.out : This causes no issue.
  • /tmp/toolchain_mips/bin/mips64el-linux-android-clang++ /tmp/test.cpp -o /tmp/32.out : This fails with the following error (adding -mips32 flag does not change the result):
/tmp/test.cpp:1:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>
         ^
1 error generated.

When looking at the system include paths (by adding -Wp,-v to the build lines), we notice that the mips32 toolchain is lacking the include/c++/4.9.x/mips64el-linux-android directory.

Here is an output of the build with -Wp,-v mips64 toolchain:

clang -cc1 version 3.8.275480 based upon LLVM 3.8.275480 default target x86_64-unknown-linux
ignoring nonexistent directory "/tmp/toolchain_mips64/bin/../sysroot/usr/local/include"
ignoring nonexistent directory "/tmp/toolchain_mips64/bin/../sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
 /tmp/toolchain_mips64/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/c++/4.9.x
 /tmp/toolchain_mips64/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/c++/4.9.x/mips64el-linux-android
 /tmp/toolchain_mips64/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/c++/4.9.x/backward
 /tmp/toolchain_mips64/bin/../lib64/clang/3.8.275480/include
 /tmp/toolchain_mips64/bin/../sysroot/usr/include
End of search list.

And the same for the mips32 toolchain:

clang -cc1 version 3.8.275480 based upon LLVM 3.8.275480 default target x86_64-unknown-linux
ignoring nonexistent directory "/tmp/toolchain_mips/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/mips64el-linux-android/c++/4.9.x/mips-r1"
ignoring nonexistent directory "/tmp/toolchain_mips/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/mipsel-none-linux-android/c++/4.9.x"
ignoring nonexistent directory "/tmp/toolchain_mips/bin/../sysroot/usr/local/include"
ignoring nonexistent directory "/tmp/toolchain_mips/bin/../sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
 /tmp/toolchain_mips/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/c++/4.9.x
 /tmp/toolchain_mips/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../include/c++/4.9.x/backward
 /tmp/toolchain_mips/bin/../lib64/clang/3.8.275480/include
 /tmp/toolchain_mips/bin/../sysroot/usr/include
End of search list.

This issue is not present on the ndk-r13b (Pkg.Revision = 13.1.3345770), which did not use the mips64el toolchain but the mipsel toolchain for 32 bits mips.

Environment Details

  • NDK Version: 14.0.3770861
  • Build sytem: standalone toolchain
  • Host OS: Linux (Ubuntu 14.04.05 LTS) & MacOS Sierra
  • Compiler: Same issue with GCC (g++) & Clang (clang++)
  • ABI: mips32
  • STL: gnustl
  • NDK API level: 21
@DanAlbert
Copy link
Member

Sorry, I'd typed out a response to this before I left work yesterday but forgot to hit send.

I'm going to give r14 a few more days to gather feedback before I kick off r14b.

I think you can work around this for now by reverting the following two patches (didn't have time to test this yesterday, but it should work):
https://android.googlesource.com/platform/ndk/+/8a20465396fdcbfe48cdaee9aceb4cea1fec3160%5E%21/#F0
https://android.googlesource.com/platform/ndk/+/6a47a9e5de4949318bd277fc05dcef9e89a3da30%5E%21/#F3

Another workaround would be to use --stl libc++, but that's a bigger hammer :)

@davidshen84
Copy link

@DanAlbert I am from #312.

I updated my build script to use mips64el-linux-android- tool prefix, and added -m32 to CFLAGS. I kick off the build again, and got this error:

/var/jenkins_home/android-16-mips-toolchain/bin/../lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/bin/ld: cannot find crtbegin_dynamic.o: No such file or directory
/var/jenkins_home/android-16-mips-toolchain/sysroot/usr/lib/libz.so: error adding symbols: File in wrong format

I checked the generated toolchain directory, and the file is there.

Probably the same issue?

@N-Bz
Copy link
Author

N-Bz commented Mar 6, 2017

@davidshen84 I guess the CFLAG to pass is -mips32, not -m32 (At least that what I pass, and it seems to work fine for plain C)

@davidshen84
Copy link

@N-Bz Tried -mips32, still got the same error.

I switched back to r13b, and my builds work well.

@DanAlbert
Copy link
Member

I've just uploaded a stack of patches to revert the broken pieces and increase our test coverage. If you want to apply the revert locally, https://android-review.googlesource.com/c/349275/ is the change that contains the fix.

@DanAlbert DanAlbert self-assigned this Mar 13, 2017
@DanAlbert DanAlbert added this to the r14b milestone Mar 13, 2017
@DanAlbert
Copy link
Member

Cherry-picked into r14.

a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
This lets us import from the NDK's python library, so we can abstract
some of this away rather than duplicating it in every similar test.

This also allows our pylintrc to apply to each test.

Test: ./validate.py --filter standalone_toolchain*
Bug: android/ndk#310
Change-Id: Ib112cca91b56009c838bc1712c8a9285a40976c1
(cherry picked from commit 4b25333)
a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
Test: ./validate.py --filter standalone_toolchain*
Bug: android/ndk#310
Change-Id: Ie65713b0cbad177b1531ebf355e6df9baafab458
(cherry picked from commit 69b99f3)
a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
https://android-review.googlesource.com/c/247064/

We need to drop this because neither Clang nor GCC is able to
correctly find the gnustl headers if only the 32-bit ones are present.

This might be worth revisiting at some point, but for now I'm just
moving standalone toolchains back to the 32-bit toolchain to get
things back into working condition. This change is working fine for
cmake and ndk-build though, so it's only a partial revert.

Tests are in the next commit so we don't accidentally revert the
tests if we revisit this.

Test: ./validate.py --filter standalone_toolchain_gnustl*
Bug: android/ndk#310
Change-Id: I2df811c5a67db9a64d3d352e08d60f660e075012
(cherry picked from commit 40d8abb)
a252539783 pushed a commit to a252539783/aosp-platform-ndk that referenced this issue May 3, 2017
Test: ./validate.py --filter standalone_toolchain_gnustl*
Bug: android/ndk#310
Change-Id: If40213bc55091898a8f9181228b6921882f0a5fa
(cherry picked from commit 78612a5)
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
This lets us import from the NDK's python library, so we can abstract
some of this away rather than duplicating it in every similar test.

This also allows our pylintrc to apply to each test.

Test: ./validate.py --filter standalone_toolchain*
Bug: android/ndk#310
Change-Id: Ib112cca91b56009c838bc1712c8a9285a40976c1
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
Test: ./validate.py --filter standalone_toolchain*
Bug: android/ndk#310
Change-Id: Ie65713b0cbad177b1531ebf355e6df9baafab458
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
https://android-review.googlesource.com/c/247064/

We need to drop this because neither Clang nor GCC is able to
correctly find the gnustl headers if only the 32-bit ones are present.

This might be worth revisiting at some point, but for now I'm just
moving standalone toolchains back to the 32-bit toolchain to get
things back into working condition. This change is working fine for
cmake and ndk-build though, so it's only a partial revert.

Tests are in the next commit so we don't accidentally revert the
tests if we revisit this.

Test: ./validate.py --filter standalone_toolchain_gnustl*
Bug: android/ndk#310
Change-Id: I2df811c5a67db9a64d3d352e08d60f660e075012
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
Test: ./validate.py --filter standalone_toolchain_gnustl*
Bug: android/ndk#310
Change-Id: If40213bc55091898a8f9181228b6921882f0a5fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants