-
Notifications
You must be signed in to change notification settings - Fork 258
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
[BUG]show “fcntl(): Bad file descriptor” #1492
Comments
the internet seems to think that this is caused by the it's unclear to me whether this is just an inherent problem on Windows? if so, i guess ndk-build should not pass |
My understanding is that this isn't a real error. Everything works correctly, it just also prints this. We see this when we run tests but all the tests behave correctly. Is this causing a problem that you're seeing, or is the bug here just "it's printing extra stuff"? |
We know, that's when we updated make and started seeing this. It just doesn't appear to cause any harm. Can you answer the question I asked in the previous comment? Is this causing a problem? We need to know how to prioritize this. |
I haven't found any problems so far, I just want to raise them first to prevent potential problems. |
I'd be happy to work on this today -- I think I recall mostly debugging it already. |
All yours :) |
Do I need to close the issue now? |
No, it can stay open. |
I filed an upstream bug with GNU make: https://savannah.gnu.org/bugs/?60444. I also attached a patch to that bug that I think would fix this issue. |
FWIW, I tried to build upstream make (with a recent, upstream gnulib) with x86_64-w64-mingw32-gcc, and was unsuccessful. I tried overriding fcntl in configure like so:
It seems that gnulib has a fcntl.h that defines F_GETFD to 2, but make already has code to define F_GETFD to 1 and F_SETLKW to 2, so we get this compiler error:
When I leave fcntl as-is, I hit a different gnulib issue:
Here the trouble is that a newer version of gnulib (i.e. newer than in the NDK source tree) adds a bunch of defines in unistd.h, like so:
make is defining its own There is a commit message suggesting that this redefining can be turned off, but I don't know how to do that. mingw-w64 and MSVC both provide the unprefixed names AFAICT, but I see MSDN docs and header annotations indicating that the unprefixed names are deprecated. I'm not sure how to make the gnulib autoconf stuff work, so my preference is to:
|
Switching to MSVC is usually a good idea. Might be more work than it's worth compared to just patching locally though. |
There is another variant of this bug that happens on macOS: On macOS, the output-sync feature tries to lock the output file, but the file locking APIs don't work on a pipe. This problem started happening with NDK r21. Gradle captures the output of ndk-build (probably using a pipe), and I see the errors with either Android Studio or running It looks like the r21e macOS make output-sync works fine if the output is a tty or a real file, but not if it's a pipe. |
For Windows, I put in a workaround in r23 beta6 / rc1: That workaround isn't in the final r23 release, though.
Maybe it was lost during the transition from git_ndk-r23-release to aosp-ndk-release-r23? I swapped out make's build system, which actually fixes this issue instead (but only on Windows, not macOS):
I suppose we want one of these fixes in r23b, but I'm not sure which. |
First option (dropping |
This option was added in r21, but it was broken with the upgrade to GNU Make 4.3. We can pass it again when make is fixed Bug: android/ndk#1492 Test: manual Change-Id: Idaddf69194ddf616249ff1671d35d3962f949d9c (cherry picked from commit 0ecc433)
This option was added in r21, but it was broken with the upgrade to GNU Make 4.3. We can pass it again when make is fixed Bug: android/ndk#1492 Test: manual Change-Id: Idaddf69194ddf616249ff1671d35d3962f949d9c (cherry picked from commit 0ecc433)
This option was added in r21, but it was broken with the upgrade to GNU Make 4.3. We can pass it again when make is fixed Bug: android/ndk#1492 Test: manual Change-Id: Idaddf69194ddf616249ff1671d35d3962f949d9c (cherry picked from commit 0ecc433)
Also create a category for all the CMake-related fixes in r23b. Bug: android/ndk#1492 Test: treehugger Change-Id: Ie74b1b42e1831fb0027a4d25c8750a6be9b5f252 (cherry picked from commit 2c7b92e)
This change stops linking gnulib's fcntl on Windows, fixing --output-sync. Bug: android/ndk#1492 Bug: android/ndk#1546 Change-Id: I8cd16eda2899451a6ae43ec1cf7008122746c576 (cherry picked from commit d5a5e29) Merged-In: I8cd16eda2899451a6ae43ec1cf7008122746c576
We're well past r23 now :) |
Is this fixed? Not screaming that this is actually causing problems, but I see something similar on macOS as well. Environment details: |
For Windows, we need to avoid cross-compiling using the configure script, because it will link with more gnulib modules than is supported. gnulib's fcntl.c module breaks --output-sync (NDK bug 1492). Instead, mimic build_w32.bat by: - building the same list of C files - copying the same gnulib headers - reusing the same config.h.W32.template file For Darwin, the host-cpu-c-abi gnulib module breaks universal builds, but it's easy to disable the module by editing config.h by hand afterwards. (Removing that module from bootstrap.conf and rerunning bootstrap might also be an option, but it changes a lot of stuff.) I created CMakeLists.txt by translating Android.bp manually. Bug: android/ndk#1492 Bug: android/ndk#1546 Change-Id: I367109233967ec6f0a1637b3ab262a234c93bc5b (cherry picked from commit 487fc28) Merged-In: I367109233967ec6f0a1637b3ab262a234c93bc5b
For Windows, we need to avoid cross-compiling using the configure script, because it will link with more gnulib modules than is supported. gnulib's fcntl.c module breaks --output-sync (NDK bug 1492). Instead, mimic build_w32.bat by: - building the same list of C files - copying the same gnulib headers - reusing the same config.h.W32.template file For Darwin, the host-cpu-c-abi gnulib module breaks universal builds, but it's easy to disable the module by editing config.h by hand afterwards. (Removing that module from bootstrap.conf and rerunning bootstrap might also be an option, but it changes a lot of stuff.) I created CMakeLists.txt by translating Android.bp manually. Bug: android/ndk#1492 Bug: android/ndk#1546 Change-Id: I367109233967ec6f0a1637b3ab262a234c93bc5b (cherry picked from commit 487fc28) Merged-In: I367109233967ec6f0a1637b3ab262a234c93bc5b
For Windows, we need to avoid cross-compiling using the configure script, because it will link with more gnulib modules than is supported. gnulib's fcntl.c module breaks --output-sync (NDK bug 1492). Instead, mimic build_w32.bat by: - building the same list of C files - copying the same gnulib headers - reusing the same config.h.W32.template file For Darwin, the host-cpu-c-abi gnulib module breaks universal builds, but it's easy to disable the module by editing config.h by hand afterwards. (Removing that module from bootstrap.conf and rerunning bootstrap might also be an option, but it changes a lot of stuff.) I created CMakeLists.txt by translating Android.bp manually. Bug: android/ndk#1492 Bug: android/ndk#1546 Change-Id: I367109233967ec6f0a1637b3ab262a234c93bc5b (cherry picked from commit 487fc28) Merged-In: I367109233967ec6f0a1637b3ab262a234c93bc5b
Host OS: Windows
NDK:22.1.7171670
I execute ndk-build.cmd under CMD, it always shows “fcntl(): Bad file descriptor”.
The text was updated successfully, but these errors were encountered: