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

r16-beta 1: cygwin: asm/types.h not found with $NDK/build/ndk-build #510

Closed
vpatilvasu opened this Issue Sep 6, 2017 · 13 comments

Comments

Projects
None yet
5 participants
@vpatilvasu

vpatilvasu commented Sep 6, 2017

Description

  • Compiling with $NDK/build/ndk-build fails with error: C:/cp/tools/ndk-r16-beta1/sysroot/usr/include\linux/types.h:21:10: fatal error: 'asm/types.h' file not found
    whereas the same code compiles with $NDK/ndk-build.cmd

  • ndk-build verbose output is here

Environment Details

  • NDK Version: r16 Beta 1
  • Build sytem: ndk-build and ndk-build.cmd
  • Host OS: Windows 7 with Cygwin
  • Compiler: Clang
  • ABI: armeabi-v7a arm64-v8a
  • STL: c++_static
  • NDK API level: 23
@alexcohn

This comment has been minimized.

alexcohn commented Sep 7, 2017

I see -isystem /cygdrive/c/cp/tools/ndk-r16-beta1/sysroot/usr/include/arm-linux-androideabi, and probably this is the line that fails. Try to run ndk-build without Cygwin, it isn't necessary since NDK r10, IIRC.

@vpatilvasu

This comment has been minimized.

vpatilvasu commented Sep 7, 2017

$NDK/ndk-build.cmd using Windows command prompt and Cygwin works fine.

However, we use Cygwin to build several projects using $NDK/build/ndk-build. Is Cygwin not going to be supported by NDK?

Also, -isystem points to correct include directory in my build configuration, then why is it not able to find asm/types.h?

@alexcohn

This comment has been minimized.

alexcohn commented Sep 8, 2017

-isystem points to correct include directory in my build configuration, then why is it not able to find asm/types.h?

Unfrotunately, clang has no way to know this. Android toolchains have been compiled without cygwin support for the last 4 years.

@enh enh changed the title from r16-beta 1: asm/types.h not found with $NDK/build/ndk-build to r16-beta 1: cygwin: asm/types.h not found with $NDK/build/ndk-build Sep 8, 2017

@alexcohn

This comment has been minimized.

alexcohn commented Sep 10, 2017

I believe that the fix for setup-toolchain.mk could be

--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -147 +147 @@
-    -isystem $(SYSROOT_INC)/usr/include/$(header_triple_$(TARGET_ARCH))
+    -isystem $$(call host-path,$(SYSROOT_INC)/usr/include/$(header_triple_$(TARGET_ARCH)))
@Nercury

This comment has been minimized.

Nercury commented Sep 11, 2017

We got the same issue compiling C++ code because include directory is set over CMAKE_C_FLAGS, which is obviously not used when compiling C++ files.

I suppose CMAKE_CXX_FLAGS should also contain this include directory, however, it is a bit strange to see include directories passed this way - CMAKE convention is to use INCLUDE_DIRECTORIES, which works with both C++ and C files.

For anyone interested, the "workaround" (which is bad BTW):

if (ANDROID)
    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
endif()
@alexcohn

This comment has been minimized.

alexcohn commented Sep 11, 2017

set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")

can be bad: e.g. -std=c99 and -std=c++11 cannot coexist in CFLAGS.

@stephenhines

This comment has been minimized.

Contributor

stephenhines commented Sep 11, 2017

Unfrotunately, clang has no way to know this. Android toolchains have been compiled without cygwin support for the last 4 years.

Can you explain what we would do differently to support Cygwin? We use mingw to build our Windows toolchains, so that might limit what we can do, but I am happy to try to make this better.

@alexcohn

This comment has been minimized.

alexcohn commented Sep 11, 2017

what we would do differently to support Cygwin?

Personally I don't think there is a single reason to worry about this. If ndk-build and cmake never use cygwin-style paths, nobody would even ask about this.

@DanAlbert

This comment has been minimized.

Member

DanAlbert commented Sep 12, 2017

Just use the Windows NDK from Cygwin. Use ndk-build.cmd instead of the bash script and it all just works.

@DanAlbert DanAlbert closed this Sep 12, 2017

@DanAlbert

This comment has been minimized.

Member

DanAlbert commented Sep 12, 2017

(if that's not the case, I'll reopen, but last time I checked this was the case)

@alexcohn

This comment has been minimized.

alexcohn commented Sep 12, 2017

Just use the Windows NDK from Cygwin

Maybe drop ndk-build from the Windows distribution, only leaving ndk-build.cmd ? I cannot think of some build scenario where this could cause troubles.

Speaking about this, many people would benefit if on Linux and Mac, you could set ndk-build.cmd to be a synonym of ndk-build. This could void all the ugly solutions that involve sniffing the OS to choose between the two scripts.

@DanAlbert

This comment has been minimized.

Member

DanAlbert commented Sep 12, 2017

Both scripts get installed to $NDK/build, but only one of them is installed directly to $NDK (depending on OS), which is the one that should be used (do they work if invoked from the other location? that's definitely not tested).

@alexcohn

This comment has been minimized.

alexcohn commented Sep 12, 2017

do they work if invoked from the other location?

On the face of it, not really well. This was the opening story here. @vpatilvasu used build/ndk-build.

only one of them is installed directly to $NDK

This is a relatively recent change that I didn't notice. Which only enforces my proposal to have only one. Maybe remove both scripts from $NDK/build so that nobody is tempted to use them the wrong way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment