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

Cross-Compiling Tao For MacOS On Linux #383

Closed
TheDarkula opened this issue May 5, 2022 · 9 comments · Fixed by #601
Closed

Cross-Compiling Tao For MacOS On Linux #383

TheDarkula opened this issue May 5, 2022 · 9 comments · Fixed by #601

Comments

@TheDarkula
Copy link

I have an initial discussion with @joseluisq here

I am trying to compile a project that depends on tao.

The issue comes down to building the carbon_hotkey files.

On a macos-latest machine, I ran these two steps:

        - name: Clone Tao
          run: git clone https://github.com/tauri-apps/tao

        - name: Build
          run: pushd tao/src/platform_impl/macos/carbon_hotkey; clang -v -mmacosx-version-min=10.12 carbon_hotkey_binding.c; popd

This outputs the same error when trying to compile on linux. The message from the runner job is this:

Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.12.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name carbon_hotkey_binding.c -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -munwind-tables -faligned-alloc-unavailable -target-sdk-version=12.1 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 711 -v -resource-dir /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0 -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -internal-isystem /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include -internal-externc-isystem /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -fdebug-compilation-dir /Users/runner/work/mellis/mellis/tao/src/platform_impl/macos/carbon_hotkey -ferror-limit 19 -stack-protector 1 -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcommon -clang-vendor-feature=+nullptrToBoolConversion -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNeonImmediateRangeCheck -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+revert09abecef7bbf -mllvm -disable-aligned-alloc-awareness=1 -mllvm -enable-dse-memoryssa=0 -o /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/carbon_hotkey_binding-8edd91.o -x c carbon_hotkey_binding.c
clang -cc1 version 13.0.0 (clang-1300.0.29.30) default target x86_64-apple-darwin20.6.0
ignoring nonexistent directory "/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include
 /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.12.0 12.1 -syslibroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o a.out -L/usr/local/lib /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/carbon_hotkey_binding-8edd91.o -lSystem /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_GetApplicationEventTarget", referenced from:
      _install_event_handler in carbon_hotkey_binding-8edd91.o
      _register_hotkey in carbon_hotkey_binding-8edd91.o
  "_GetEventParameter", referenced from:
      _hotkey_handler in carbon_hotkey_binding-8edd91.o
  "_InstallEventHandler", referenced from:
      _install_event_handler in carbon_hotkey_binding-8edd91.o
  "_RegisterEventHotKey", referenced from:
      _register_hotkey in carbon_hotkey_binding-8edd91.o
  "_RemoveEventHandler", referenced from:
      _uninstall_event_handler in carbon_hotkey_binding-8edd91.o
  "_UnregisterEventHotKey", referenced from:
      _unregister_hotkey in carbon_hotkey_binding-8edd91.o
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: Process completed with exit code 1.

Is there something simple I am missing here?

@elonzyy
Copy link

elonzyy commented Jul 17, 2022

Same here trying to cross compile from Linux to Macos using osxcross.
The upstream crate doesn't support Macos: https://github.com/jamesbirtles/hotkey-rs

@TheDarkula
Copy link
Author

@elonzyy Ah. Great digging!

@TheDarkula
Copy link
Author

@elonzyy I did some more digging, and I do not see the hotkey-rs crate anywhere in tao's dependencies in the output of cargo tree.

Am I missing something?

@amrbashir amrbashir added platform: macOS status: waiting Waiting for a response or another PR and removed platform: macOS status: waiting Waiting for a response or another PR labels Jul 22, 2022
@amrbashir
Copy link
Member

Sorry for the delayed response.

global_shortcut module used a lot of hotkey-rs code but we don't depend on it directly.

We recently discussed the removal of global_shortcut module and instead let users build their own global shortcut manager on top of DeviceEvent::Key. This is part of our efforts to move back to directly depend on winit but there is no timeline when will this happen but definitely before tauri v2.

I will leave this issue open until then or if someone makes a PR for an alternative to using carbon APIs.

@dvc94ch
Copy link
Contributor

dvc94ch commented Oct 23, 2022

Just FYI the issue you encountered is the build script not running when building for mac on a Linux machine. the target os for the build script is Linux in that case.

@jost-s
Copy link

jost-s commented Feb 3, 2023

I get an error when compiling for x86_64-darwin platform:

error: failed to run custom build command for `tao v0.15.8`
launcher-deps> Caused by:
launcher-deps>   process didn't exit successfully: `/private/tmp/nix-build-launcher-deps-0.0.1.drv-0/source/target/release/build/tao-5d07c06194b9de70/build-script-build` (exit status: 1)
launcher-deps>   --- stdout
launcher-deps>   cargo:rustc-link-lib=framework=Carbon
launcher-deps>   TARGET = Some("x86_64-apple-darwin")
launcher-deps>   OPT_LEVEL = Some("3")
launcher-deps>   HOST = Some("x86_64-apple-darwin")
launcher-deps>   cargo:rerun-if-env-changed=CC_x86_64-apple-darwin
launcher-deps>   CC_x86_64-apple-darwin = None
launcher-deps>   cargo:rerun-if-env-changed=CC_x86_64_apple_darwin
launcher-deps>   CC_x86_64_apple_darwin = None
launcher-deps>   cargo:rerun-if-env-changed=HOST_CC
launcher-deps>   HOST_CC = None
launcher-deps>   cargo:rerun-if-env-changed=CC
launcher-deps>   CC = Some("clang")
launcher-deps>   cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-darwin
launcher-deps>   CFLAGS_x86_64-apple-darwin = None
launcher-deps>   cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_darwin
launcher-deps>   CFLAGS_x86_64_apple_darwin = None
launcher-deps>   cargo:rerun-if-env-changed=HOST_CFLAGS
launcher-deps>   HOST_CFLAGS = None
launcher-deps>   cargo:rerun-if-env-changed=CFLAGS
launcher-deps>   CFLAGS = None
launcher-deps>   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
launcher-deps>   CRATE_CC_NO_DEFAULTS = None
launcher-deps>   DEBUG = Some("false")
launcher-deps>   running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-apple-darwin" "-Wall" "-Wextra" "-o" "/private/tmp/nix-build-launcher-deps-0.0.1.drv-0/source/target/release/build/tao-261b53ae95382f24/out/src/platform_impl/macos/carbon_hotkey/carbon_hotkey_binding.o" "-c" "src/platform_impl/macos/carbon_hotkey/carbon_hotkey_binding.c"
launcher-deps>   cargo:warning=In file included from src/platform_impl/macos/carbon_hotkey/carbon_hotkey_binding.c:7:
launcher-deps>   cargo:warning=In file included from /nix/store/9g99yn2v6qvjz0jka4f0ikdv90x3hng1-apple-framework-Carbon-11.0.0/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20:
launcher-deps>   cargo:warning=In file included from /nix/store/1wzdsghj5nk25xbrf715izgz6z62dlsp-apple-framework-CoreServices-11.0.0/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:
launcher-deps>   cargo:warning=In file included from /nix/store/pijg4pkqizi263fp9l023k5a91245qf6-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:60:
launcher-deps>   cargo:warning=In file included from /nix/store/pijg4pkqizi263fp9l023k5a91245qf6-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:17:
launcher-deps>   cargo:warning=In file included from /nix/store/pijg4pkqizi263fp9l023k5a91245qf6-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:16:
launcher-deps>   cargo:warning=/nix/store/pijg4pkqizi263fp9l023k5a91245qf6-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1189:83: error: expected ','
launcher-deps>   cargo:warning=    kCFURLBookmarkCreationWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0))  API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched

There are many more warnings which contain the API_UNAVAILABLE part. Is this a related error?

It compiles fine for aarch64-darwin/arm64 on macos. Is it to do with the supported macos version?

@wusyong
Copy link
Member

wusyong commented Feb 4, 2023

yeah it might be related to the version because we still use C bindings for carbon framework.
@amrbashir do you think we can remove this binding since we already have a crate for global hotkey?

@amrbashir
Copy link
Member

the muda branch in tao should have all this removed so you can use global-hotkey crate without problems

@amrbashir
Copy link
Member

I will start on removing these bits from tauri and mugrate to the new crates so we could merge the muda branch in dev.

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

Successfully merging a pull request may close this issue.

6 participants