Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ if(LINUX OR APPLE)
# comes from; probably a XCode preset?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
endif()
add_definitions(-D__MAC_OS_X_VERSION_MIN_REQUIRED=140000)
Copy link
Copy Markdown
Contributor

@duburcqa duburcqa Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should rather specify:

              -DCMAKE_OSX_ARCHITECTURES="${OSX_ARCHITECTURES}" \
              -DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET}" \

with

      OSX_DEPLOYMENT_TARGET: "11.0"
      OSX_ARCHITECTURES: "x86_64;arm64"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will give it a shot, and see what happens. (I'm using generic clang, not OS X clang, so it's unclear to me whether these will be honored => will try, and report back on what happens).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this. Here is the new code:

if(LINUX OR APPLE)
    if (NOT IOS)
        # (penguinliong) Not compatible with -fembed-bitcode. Not sure where it
        # comes from; probably a XCode preset?
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
    endif()
    set(CMAKE_OSX_DEPLOYMENT_TARGET "14.0")
    set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
endif()

Result:

/Users/hugh/.cache/ti-build-cache/sccache-v041/bin/sccache /opt/homebrew/opt/llvm@15/bin/clang++  -I/Users/hugh/.cache/ti-build-cache/miniforge/envs/3.10/lib/python3.10/site-packages/numpy/_core/include -I/Users/hugh/git/taichi -I/Users/hugh/git/taichi/external/SPIRV-Cross -I/Users/hugh/git/taichi/external/spdlog/include -I/Users/hugh/git/taichi/external/glad/include -I/Users/hugh/git/taichi/external/glfw/include -ffunction-sections -fdata-sections -DTI_ISE_NONE -std=c++17 -fsized-deallocation -Wno-deprecated-declarations -Wno-shorten-64-to-32 -Wall  -Werror  -Wno-ignored-attributes  -Wno-nullability-completeness  -Wno-unused-private-field  -Wno-unneeded-internal-declaration  -Wno-unused-but-set-variable  -DTI_ARCH_ARM -DTI_PASS_EXCEPTION_TO_PYTHON -DTI_INCLUDED -fno-objc-arc -DTI_WITH_LLVM -DTI_WITH_METAL -DTI_WITH_METAL -O3 -DNDEBUG -std=gnu++17 -arch x86_64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk -mmacosx-version-min=14.0 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o -MF taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o.d -o taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o -c /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.mm
In file included from /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.mm:7:
In file included from /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:626:74: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:626:104: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:642:24: error: unknown type name 'NSInteger'
typedef NS_CLOSED_ENUM(NSInteger, NSComparisonResult) {
                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:642:24: error: unknown type name 'NSInteger'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:650:20: error: unknown type name 'NSUInteger'
typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions) {
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:655:20: error: unknown type name 'NSUInteger'
typedef NS_OPTIONS(NSUInteger, NSSortOptions) {
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:660:17: error: unknown type name 'NSInteger'
typedef NS_ENUM(NSInteger, NSQualityOfService) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(tested on this branch, https://github.com/genesis-company/taichi/tree/hp/mac-fix-metal-device-change-approach2 (since have to enable mac build etc, which isnt enabled on this PR branch yet))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove x86 actually because Metal is not available on old Intel MacBook.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSUIinteger needs TARGET_OS_OSX to be defined.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Note: I'm not intending to cross-compile here. What makes you feel I am cross-compiling? 🤔 )

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh -arch x86_64. Alright, I'll remove that. But the errors will persist I predict :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with x86 removed:

FAILED: taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o
/Users/hugh/.cache/ti-build-cache/sccache-v041/bin/sccache /opt/homebrew/opt/llvm@15/bin/clang++  -I/Users/hugh/.cache/ti-build-cache/miniforge/envs/3.10/lib/python3.10/site-packages/numpy/_core/include -I/Users/hugh/git/taichi -I/Users/hugh/git/taichi/external/SPIRV-Cross -I/Users/hugh/git/taichi/external/spdlog/include -I/Users/hugh/git/taichi/external/glad/include -I/Users/hugh/git/taichi/external/glfw/include -ffunction-sections -fdata-sections -DTI_ISE_NONE -std=c++17 -fsized-deallocation -Wno-deprecated-declarations -Wno-shorten-64-to-32 -Wall  -Werror  -Wno-ignored-attributes  -Wno-nullability-completeness  -Wno-unused-private-field  -Wno-unneeded-internal-declaration  -Wno-unused-but-set-variable  -DTI_ARCH_ARM -DTI_PASS_EXCEPTION_TO_PYTHON -DTI_INCLUDED -fno-objc-arc -DTI_WITH_LLVM -DTI_WITH_METAL -DTI_WITH_METAL -O3 -DNDEBUG -std=gnu++17 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk -mmacosx-version-min=14.0 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o -MF taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o.d -o taichi/rhi/metal/CMakeFiles/metal_rhi.dir/metal_device.mm.o -c /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.mm
In file included from /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.mm:7:
In file included from /Users/hugh/git/taichi/taichi/rhi/metal/metal_device.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:626:74: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:626:104: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:642:24: error: unknown type name 'NSInteger'
typedef NS_CLOSED_ENUM(NSInteger, NSComparisonResult) {
                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:642:24: error: unknown type name 'NSInteger'
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:650:20: error: unknown type name 'NSUInteger'
typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions) {
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:655:20: error: unknown type name 'NSUInteger'
typedef NS_OPTIONS(NSUInteger, NSSortOptions) {
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:660:17: error: unknown type name 'NSInteger'
typedef NS_ENUM(NSInteger, NSQualityOfService) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see. Probably related to using classic clang instead of the one provided with Xcode.

add_definitions(-DTARGET_OS_OSX)
endif()

if (USE_LLD)
Expand Down