darlinghq / darling

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

TARGET_OS_DRIVERKIT missing under Clang 12 #856

Closed rdrpenguin04 closed 3 years ago

rdrpenguin04 commented 4 years ago

I should mention that this is a git build of Clang and of CMake; let me know if you want more precise version information.

Build Log Relevant section (omitted successful targets):

[13/15893] Building CXX object src/dyld/CMakeFiles/system_loader.dir/src/dyld2.o
FAILED: src/dyld/CMakeFiles/system_loader.dir/src/dyld2.o 
/usr/bin/ccache /usr/local/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/local/lib/clang/12.0.0/include -Wno-nullability-completeness -Wno-deprecated-declarations -Wno-expansion-to-defined -std=c++17 -Wno-availability -include /home/rdrpenguin/darling/src/duct/include/CrashReporterClient.h   -target x86_64-apple-darwin11 -nostdinc  -DBUILDING_DYLD=1 -gfull -fno-pic -B /home/rdrpenguin/darling/build/src/external/cctools-port/cctools/misc/ -arch i386 -arch x86_64 -MD -MT src/dyld/CMakeFiles/system_loader.dir/src/dyld2.o -MF src/dyld/CMakeFiles/system_loader.dir/src/dyld2.o.d -o src/dyld/CMakeFiles/system_loader.dir/src/dyld2.o -c ../src/dyld/src/dyld2.cpp
clang-12: 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-12: 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]
In file included from ../src/dyld/src/dyld2.cpp:98:
In file included from ../src/dyld/src/dyld2.h:31:
../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/dyld2.cpp:98:
In file included from ../src/dyld/src/dyld2.h:31:
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)
     ^
2 errors generated.
ninja: build stopped: subcommand failed.

System Information What system are you building with?

Software Version
Clang 12.0.0
CMake 3.17.3
Linux Kernel 5.4.0
Darling fa5348c8a9b338746b91a53a801343a8d046a66d
rdrpenguin04 commented 4 years ago

I should also mention that I am using Ninja rather than Makefile; is this a Ninja-related issue?

facekapow commented 4 years ago

I should also mention that I am using Ninja rather than Makefile; is this a Ninja-related issue?

No, this looks like a new flag introduced with Clang 11/12 and enabled by default. You should be able to get around it for now by adding -DCMAKE_C_FLAGS="-Wno-error=undef-prefix" -DCMAKE_CXX_FLAGS="-Wno-error=undef-prefix" (you might need to play around with that, though; I haven't seen this flag before and I can't find it in Clang's docs), or, if that doesn't work, then try -DCMAKE_C_FLAGS="-DTARGET_OS_DRIVERKIT=0" -DCMAKE_CXX_FLAGS="-DTARGET_OS_DRIVERKIT=0".

Be warned, though: we test Darling to build with the latest released Clang (which ATM is Clang 10), so you might run into issues with Clang 12.

rdrpenguin04 commented 4 years ago

Okay, good to know! It seems to be building fine now; I'll update you if it doesn't.

This seems like an easy issue to fix, something like ifndef, define, endif. Let me know if you need anything else!

teras commented 3 years ago

I was able to go forward with this error, just to fail a bit later with this error:

In file included from /tmp/yaourt-tmp-teras/aur-darling/src/darling/src/external/libdispatch/src/block.cpp:32:
In file included from /tmp/yaourt-tmp-teras/aur-darling/src/darling/src/external/libdispatch/src/internal.h:1086:
In file included from /tmp/yaourt-tmp-teras/aur-darling/src/darling/src/external/libdispatch/src/object_internal.h:472:
/tmp/yaourt-tmp-teras/aur-darling/src/darling/src/external/objc4/runtime/include/objc/runtime.h:1547:9: error: non-defining declaration of enumeration with a fixed underlying type is only permitted as a standalone declaration; missing list of enumerators? [-Welaborated-enum-base]
typedef OBJC_ENUM(uintptr_t, objc_AssociationPolicy) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/yaourt-tmp-teras/aur-darling/src/darling/src/external/objc4/runtime/include/objc/objc-api.h:221:44: note: expanded from macro 'OBJC_ENUM'
#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
                                           ^~~~~~~

I tried to add the option -Welaborated-enum-base but with no luck (as mentioned here)

lmtr0 commented 3 years ago

same

rdrpenguin04 commented 3 years ago

That is a separate issue, I recommend reporting it as such.

I may submit a PR to fix this at some point, since that seems to be the way it'll get fixed.

rdrpenguin04 commented 3 years ago

Fixed in update-sources, closing.

facekapow commented 3 years ago

Reopening this until update-sources merges.

xero-lib commented 3 years ago

Fixed in update-sources, closing.

Pardon my stupidity, but might you elaborate? I'm still getting error: 'TARGET_OS_DRIVERKIT' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]

CuriousTommy commented 3 years ago

Pardon my stupidity, but might you elaborate?

update-sources is another branch. You can use the follow commands to checkout that branch.

git checkout update-sources
git submodule update --init --recursive
iwsmike commented 3 years ago

git submodule update --init --recursive

found this as I was running make a few minutes ago, will let you know if it works.

https://user-images.githubusercontent.com/44496172/103835979-fd92de80-5087-11eb-946a-26c5eaa8e717.mp4

iwsmike commented 3 years ago

git submodule update --init --recursive

found this as I was running make a few minutes ago, will let you know if it works.

deepin-screen-recorder_gnome-terminal-server_20210107013026.mp4

28% and progressing

iwsmike commented 3 years ago

git submodule update --init --recursive

found this as I was running make a few minutes ago, will let you know if it works. deepin-screen-recorder_gnome-terminal-server_20210107013026.mp4

28% and progressing

https://user-images.githubusercontent.com/44496172/103842199-9f6cf800-5095-11eb-8101-fdab6d1ddaee.mp4

88%, it sure is taking time (samsung 2Tb nvme 960 pro, 20 cores, 64g DDR4) but so far so good

iwsmike commented 3 years ago

@CuriousTommy 4h but all ok. Thanks!