darlinghq / darling

Darwin/macOS emulation layer for Linux
http://www.darlinghq.org
GNU General Public License v3.0
11.43k stars 442 forks source link

-Werror,-Wundef-prefix=TARGET_OS_ breaks the build on WSL2 #908

Closed IngwiePhoenix closed 3 years ago

IngwiePhoenix commented 3 years ago

Build Log A lot of these:

ingwie@DESKTOP-LMR6I2A /o/d/out $ ninja -j 1
[1/9707] Building CXX object src/dyld/CMakeFiles/system_dyld_obj.dir/src/dyldAPIsInLibSystem.o
FAILED: src/dyld/CMakeFiles/system_dyld_obj.dir/src/dyldAPIsInLibSystem.o
/usr/bin/clang++  -DDARLING -DDARWIN -DHAVE_STDINT_H=1 -DTARGET_OS_MAC=1 -D_DARWIN_C_SOURCE -D_LIBCPP_NO_EXCEPTIONS=1 -D_LIBC_NO_FEATURE_VERIFICATION -D_POSIX_C_SOURCE -D__APPLE__ -D__DYNAMIC__ -D__MACH__ -I../src/dyld/src -I../src/dyld/dyld3 -I../src/dyld/dyld3/shared-cache -I../src/dyld/include/mach-o -I../src/dyld/include -I../src/external/libcxx/include -Isrc/include -I../src/include -I../src/libc/include -I../src/external/libplatform/include -I../platform-include -I../platform-include/pthread -I../src/libc/derived -I../src/libc/include/NetBSD -I../src/libc/include/FreeBSD -I../src/kernel/libsyscall/wrappers -I../src/kernel/include -I../kernel-include -I../src/duct/include -I../src/libm/include -I../src/simd/include -I../src/CoreAudio/include -I../src/external/SmartCardServices/include -I../src/external/IOKitUser/include -I../src/launchd/liblaunch/include -I../src/sandbox/include -I../src/external/coretls/include -I../src/libmalloc/include -I../src/libinfo/include -I../src/external/syslog/libsystem_asl.tproj/include -I../src/external/openssl/src/include -I../kernel-include/iokit -I../src/external/IOKitUser -I../src/external/openpam/include -I../src/external/sqlite/include -I../src/OpenScripting/include -I../src/libiconv/include -I../src/ncurses/include -I../src/external/corefoundation/include -I../src/external/foundation/include -I../src/external/objc4/runtime/include -I../src/external/corecrypto/include -I../src/external/security/include -I../src/xcselect/include -I../src/libaks/include -I../src/external/icu/include -I../src/external/libpthread/include -I../src/libremovefile/include -I../src/external/libdispatch/include -I../src/external/libclosure/include -I../src/external/cfnetwork/include -I../src/external/cfnetwork/private_include -I../src/external/libxml2/include -Isrc/external/libxml2/include -I../src/external/expat/include -I../src/libedit/include -I../src/external/bzip2/include -I../src/libnotify/include -I../src/opendirectory_internal/include -I../src/external/commoncrypto/include -I../src/quarantine/include -I../src/libpmenergy/include -I../src/copyfile/include -I../src/external/zlib/include -I../src/xar/include -I../src/external/DirectoryService/include -I../src/libresolv/include -I../src/external/cocotron/include -I../src/external/cocotron/AppKit/include -I../src/external/cocotron/CoreText/include -I../src/external/cocotron/QuartzCore/include -I../src/external/cocotron/CoreGraphics/include -I../src/external/cocotron/Onyx2D/include -I../src/external/cocotron/CoreData/include -I../src/external/WTF/include -I../src/external/bmalloc/include -I../src/libsysmon/include -I../src/libcompression/include -I../src/external/dtrace/head -I../src/external/lkm/include -I../src/libDiagnosticMessagesClient/include -I../src/libquit/include -I../src/external/SecurityTokend/include -I../src/external/lzfse/include -I../src/libsandbox/include -I../src/OpenDirectory/include -I../src/frameworks/include -I../src/private-frameworks/include -I../src/lib/include -I../src/launchd/liblaunch -I../src/libc/darwin -I../src/libc/gen -I../src/libc/locale -I../src/libc/locale/FreeBSD -I../src/libc/stdtime/FreeBSD -I../src/kernel/libsyscall/wrappers/libproc -I../src/kernel/emulation/linux/misc -I../src -I../src/sandbox -I../src/external/libclosure -I../src/libutil -I../src/dyld/launch-cache -I../src/dyld -isystem /usr/lib/llvm-11/lib/clang/11.0.1/include -Wno-nullability-completeness -Wno-deprecated-declarations -Wno-expansion-to-defined -std=c++17 -Wno-availability -include /opt/darling/src/duct/include/CrashReporterClient.h   -target x86_64-apple-darwin11 -nostdinc  -B /opt/darling/out/src/external/cctools-port/cctools/misc/ -arch i386 -arch x86_64 -fno-exceptions -fno-rtti -DBUILDING_LIBDYLD=1 -MD -MT src/dyld/CMakeFiles/system_dyld_obj.dir/src/dyldAPIsInLibSystem.o -MF src/dyld/CMakeFiles/system_dyld_obj.dir/src/dyldAPIsInLibSystem.o.d -o src/dyld/CMakeFiles/system_dyld_obj.dir/src/dyldAPIsInLibSystem.o -c ../src/dyld/src/dyldAPIsInLibSystem.cpp
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
../src/dyld/src/dyldAPIsInLibSystem.cpp:34:6: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if !TARGET_OS_DRIVERKIT
     ^
In file included from ../src/dyld/src/dyldAPIsInLibSystem.cpp:50:
../src/dyld/src/ImageLoader.h:46:6: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if !TARGET_OS_DRIVERKIT && (BUILDING_LIBDYLD || BUILDING_DYLD)
     ^
In file included from ../src/dyld/src/dyldAPIsInLibSystem.cpp:50:
In file included from ../src/dyld/src/ImageLoader.h:53:
In file included from ../src/dyld/dyld3/shared-cache/DyldSharedCache.h:41:
In file included from ../src/dyld/dyld3/MachOAnalyzer.h:28:
In file included from ../src/dyld/dyld3/MachOLoaded.h:29:
../src/dyld/dyld3/Array.h:33:6: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if !TARGET_OS_DRIVERKIT && (BUILDING_LIBDYLD || BUILDING_DYLD)
     ^
../src/dyld/src/dyldAPIsInLibSystem.cpp:85:41: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if __IPHONE_OS_VERSION_MIN_REQUIRED || TARGET_OS_DRIVERKIT
                                        ^
../src/dyld/src/dyldAPIsInLibSystem.cpp:1381:5: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_DRIVERKIT
    ^
../src/dyld/src/dyldAPIsInLibSystem.cpp:1488:6: error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if !TARGET_OS_DRIVERKIT
     ^
6 errors generated.
ninja: build stopped: subcommand failed.

Tried to grep -r "undef-prefix" $darlingsrc_root but found nothing. Where'd that come from?

System Information What system are you building with?

Software Version
Clang 11.0.1
CMake 3.13.4
Linux Kernel 4.19.128-microsoft-standard (WSL2/Debian 10)
Darling 1d3b09970856d58d12867f4ee5b9b1bf84cd05c2
IngwiePhoenix commented 3 years ago

For further context, TARGET_OS_OSX and TARGET_OS_LINUX also show up a lot. I ran with ninja -k 1000 to see how far the build gets - but these undefined macros just break the build :/

IngwiePhoenix commented 3 years ago

Taking another look at one of the failing commands, I spot these:

-Wno-nullability-completeness
-Wno-deprecated-declarations
-Wno-expansion-to-defined
-std=c++17
-Wno-availability

None of them strike me as implicy specifying -Werror as the message above shows, let alone disabling TARGET_OS_ defines. I am a little lost to be honest.

HinTak commented 3 years ago

This is the same issue as https://github.com/darlinghq/darling/issues/856

IngwiePhoenix commented 3 years ago

I'll give the solution given there a shot. Though, I use Clang 11. Anyway, will come back with a result later.

IngwiePhoenix commented 3 years ago

Yup, that worked. But I also ran into the same issue regarding the enums... Anyway, core issue solved, closing.