Skip to content
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

Cannot compiler profiler on macOS 12.3.1 #368

Closed
jdumas opened this issue Apr 20, 2022 · 9 comments
Closed

Cannot compiler profiler on macOS 12.3.1 #368

jdumas opened this issue Apr 20, 2022 · 9 comments

Comments

@jdumas
Copy link

jdumas commented Apr 20, 2022

Hi,

I recently upgraded my macOS to 12.3.1 and now I cannot build the profiler anymore, stumbling upon this issue:

❯ make -j4 release
cc -c -I/usr/local/Cellar/glfw/3.3.7/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/capstone/4.0.2/include/capstone -I../../../imgui -O3 -flto -march=native  -DNDEBUG -DIMGUI_ENABLE_FREETYPE ../../../nfd/nfd_cocoa.m -o obj/release/o/o/o/../../../nfd/nfd_cocoa.o
In file included from ../../../nfd/nfd_cocoa.m:7:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos...
                                                         ~~~~~~~~~~~~~~                                                                       ^                  ~
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
        #define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
                                                      ^          ~
In file included from ../../../nfd/nfd_cocoa.m:7:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:130:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:168: error: expected ')'
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullabl...
                                                                                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:141: note: to match this '('
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullabl...
                                                                                                                                            ^
../../../nfd/nfd_cocoa.m:54:17: warning: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead [-Wdeprecated-declarations]
        [dialog setAllowedFileTypes:allowedFileTypes];
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here
@property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10.3,12.0));
                                                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
1 warning and 2 errors generated.
make[1]: *** [obj/release/o/o/o/../../../nfd/nfd_cocoa.o] Error 1
make: *** [release] Error 2

This is with Tracy 0.8.

@wolfpld
Copy link
Owner

wolfpld commented Apr 20, 2022

You can workaround by building with TRACY_NO_FILESELECTOR. This will of course disable the file selector, but you can open traces by passing them as an argument to the profiler executable, and a default file name will be selected when saving a trace.

@jdumas
Copy link
Author

jdumas commented Apr 20, 2022

Thanks. I'm using this workaround for now :)

@wolfpld
Copy link
Owner

wolfpld commented Apr 20, 2022

I have switched the NFD library to a maintained fork (https://github.com/btzy/nativefiledialog-extended). Please check if the issue still persists (macOS is a madhouse, I don't know how to switch to the SDK you are using) and if it still is, please report an issue directly in the NFD library.

@jdumas
Copy link
Author

jdumas commented Apr 20, 2022

Hmm so I tried again, and the error persists. There is clearly an issue with NFD, but I think there is also something funny going on with the makefile. I have xcode-select pointing to Xcode12.4:

❯ xcode-select -p                                                                                                                                                                                        (lagrange)
/Applications/Xcode12.4.app/Contents/Develope

And this version of cc:

❯ cc --version                                                                                                                                                                                           (lagrange)
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

When compiling Tracy, the following line is invoked to compile nfd_cocoa.m (which results in failure):

cc -c -I/usr/local/Cellar/glfw/3.3.7/include -I/usr/local/opt/freetype/include/freetype2 -I/usr/local/Cellar/capstone/4.0.2/include/capstone -I../../../imgui -O3 -flto -march=native  -DNDEBUG -DIMGUI_ENABLE_FREETYPE ../../../nfd/nfd_cocoa.m -o obj/release/o/o/o/../../../nfd/nfd_cocoa.o

But if I download https://github.com/btzy/nativefiledialog-extended separately and try to build it with CMake, it succeeds, and make VERBOSE=1 shows nfd_cocoa.m was compiled with the following arguments:

/Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -I/Users/jedumas/external/git/nativefiledialog-extended/src/include -isysroot /Applications/Xcode12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -nostdlib -fno-exceptions -fno-rtti -MD -MT src/CMakeFiles/nfd.dir/nfd_cocoa.m.o -MF CMakeFiles/nfd.dir/nfd_cocoa.m.o.d -o CMakeFiles/nfd.dir/nfd_cocoa.m.o -c /Users/jedumas/external/git/nativefiledialog-extended/src/nfd_cocoa.m

Anyhow, the -isysroot <> arg is doing the trick here. For some reason without it the makefile will pick up the macOS SDK from /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk which causes the compilation issue.

EDIT: Opened an issue on https://github.com/btzy/nativefiledialog-extended as well.

@btzy
Copy link

btzy commented Apr 21, 2022

Apple Clang version 12.0.0 is based on LLVM 10.0.0, which doesn't have _Nullable_result. The oldest version with that attribute is LLVM 12.0.0, which corresponds to Apple Clang version 13.0.0, but I recommend upgrading to the latest version of Apple Clang, which is 13.1.6.

I'm guessing that only the deprecation warning for setAllowedFileTypes is due to NFD; the two errors are due to compiling the new macOS SDK with an old compiler.

@btzy
Copy link

btzy commented May 21, 2022

I've made a fix for the NFD warning due to using the deprecated method. Can you try compiling against the branch in this PR and see if it works for you? On MacOS >= 12.0, it will instead use setAllowedContentTypes and the UniformTypeIdentifiers library, which is the "modern" way of doing things on MacOS. There is a check at runtime to determine if it is running on MacOS >= 12.0, which is required because the UniformTypeIdentifiers library may not be available on old versions of MacOS.

Note that this may be a breaking change on MacOS >= 12.0 if you are using custom file extensions. If that is the case, you will need to add an Info.plist file to your app to define your custom file extension, as per the documentation. Going forward, the setAllowedFileTypes method will probably be removed, so this will eventually be the only way to make custom file extensions work on MacOS.

@wolfpld
Copy link
Owner

wolfpld commented Jul 3, 2022

Fix from NFD repo is applied in 3c49dea.

@wolfpld wolfpld closed this as completed Jul 3, 2022
@btzy
Copy link

btzy commented Jul 13, 2022

The runtime MacOS version check caused problems for some people, and has now been replaced by a compile-time check (which presumably is the more correct way to do it, since the deprecation warning is emitted based on the compile-time target). Please pull the latest NFD version from the repo.

@wolfpld
Copy link
Owner

wolfpld commented Jul 17, 2022

Updated in d6a607b. Thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants