tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.81k stars 320 forks source link

`@available` not working #346

Closed divVerent closed 2 years ago

divVerent commented 2 years ago

Please help debug this error:

Program:

int main() {                            
        if (@available(macOS 10.14, iOS 12.0, *)) {
                return 1;
        }
        return 0;
}

fails with:

$ ~/src/osxcross-sdk/bin/o64-clang -o foo foo.m                       
Undefined symbols for architecture x86_64:
  "___isOSVersionAtLeast", referenced from:
      _main in foo-56b675.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

On a Mac with current Xcode this builds and works just fine.

divVerent commented 2 years ago

For my concrete use case, I can drop High Sierra support and require Mojave as minimum; with MACOSX_DEPLOYMENT_TARGET=10.14, above check compiles to nothing, sidestepping the bug.

akien-mga commented 2 years ago

Duplicate of #278, you need to build compiler-rt for this to work.

See the "Note:" in the README.md: https://github.com/tpoechtrager/osxcross#how-does-it-work

divVerent commented 2 years ago

Yeah, sorry; closing but will open a new one as I can't actually build that thing.