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

binaryen has started to require CMAKE_OSX_DEPLOYMENT_TARGET of 10.14 #4299

Closed
sbc100 opened this issue Nov 1, 2021 · 30 comments
Closed

binaryen has started to require CMAKE_OSX_DEPLOYMENT_TARGET of 10.14 #4299

sbc100 opened this issue Nov 1, 2021 · 30 comments

Comments

@sbc100
Copy link
Member

sbc100 commented Nov 1, 2021

When we started using std::variant we inadvertently started requiring a 10.14 macOS deployment target.

This went unnoticed on the emscripten-releases builder because there we use out own version of libc++.

However for other users, such as those who want to build from source using emsdk, this is a new requirement and emsdk
currently pins CMAKE_OSX_DEPLOYMENT_TARGET to 10.11:

https://github.com/emscripten-core/emsdk/blob/2b3e0b91761ed8962a7c4eb84d8a288819e106d7/emsdk.py#L1061-L1063

I guess we either need to remove the requirements of binaryen or relax the requirements of emsdk.

sbc100 added a commit to emscripten-core/emsdk that referenced this issue Nov 1, 2021
I add to temporarily disable the test_binaryen_from_source test
under macOS to work around:
WebAssembly/binaryen#4299
@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

One option is to temporarily revert the use of std::variant in binaryen? @tlively would that be reasonable?

sbc100 added a commit that referenced this issue Nov 1, 2021
This version represents that current reality although we
would like to lower this for increased compatibility. See: #4299
@dschuff
Copy link
Member

dschuff commented Nov 1, 2021

However for other users, such as those who want to install using emsdk, this is a new requirement and emsdk
currently pins CMAKE_OSX_DEPLOYMENT_TARGET to 10.11:

I think this should be "those who want to build using emsdk". Those who just install are using the Chromium builds and are unaffected.

@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

However for other users, such as those who want to install using emsdk, this is a new requirement and emsdk
currently pins CMAKE_OSX_DEPLOYMENT_TARGET to 10.11:

I think this should be "those who want to build using emsdk". Those who just install are using the Chromium builds and are unaffected.

Thanks, clarified.

@kripken
Copy link
Member

kripken commented Nov 1, 2021

One option is to temporarily revert the use of std::variant in binaryen?

A variation (edit: no pun intended) on that could be to replace the current std::variant with a userspace replacement with similar syntax.

@dschuff
Copy link
Member

dschuff commented Nov 1, 2021

@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

Nice! That looks like it could work.

sbc100 added a commit to emscripten-core/emsdk that referenced this issue Nov 1, 2021
I add to temporarily disable the test_binaryen_from_source test
under macOS to work around:
WebAssembly/binaryen#4299
sbc100 added a commit to emscripten-core/emsdk that referenced this issue Nov 1, 2021
I add to temporarily disable the test_binaryen_from_source test
under macOS to work around:
WebAssembly/binaryen#4299
@tlively
Copy link
Member

tlively commented Nov 1, 2021

Yikes! It looks like std::visit is also affected: https://stackoverflow.com/questions/52310835/xcode-10-call-to-unavailable-function-stdvisit/53868971.

Using std::get_if exclusively should work ok technically, but do we have a way to automatically enforce that?

@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

This should enforce it: #4300

@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

This should enforce it: #4300

Once we set it to something lower..

@sbc100
Copy link
Member Author

sbc100 commented Nov 1, 2021

If we land #4300 then part of the fix for this issue will be to lower CMAKE_OSX_DEPLOYMENT_TARGET back to 10.11 (which is what emsdk currently needs/wants).

sbc100 added a commit that referenced this issue Nov 2, 2021
This version represents that current reality although we
would like to lower this for increased compatibility. See: #4299
@juj
Copy link
Collaborator

juj commented Nov 2, 2021

Currently Unity 2021.2 requires macOS 10.13 or newer: https://docs.unity3d.com/2021.2/Documentation/Manual/system-requirements.html . (With new Emscripten releases, we are targeting Unity 2021.2 and higher)

Asked the question internally about when Unity would be bumping the minimum requirement up to macOS 10.14, and it looks like the now upcoming LTS version "2021.3" will still have macOS 10.13 support, and LTSes are supported for two years minimum, so that means that we'll be seeing macOS 10.13 based support phase out at the end of 2023 the earliest.

As a sidenote, the current CMAKE_OSX_DEPLOYMENT_TARGET of 10.11 in emsdk was set to that just because that was the lowest observed number that we knew that LLVM would successfully build with. We do not actually care about macOS < 10.13, so we are comfortable with hoisting that 10.11 to 10.13 as the minimum required version if that helps any.

@juj
Copy link
Collaborator

juj commented Nov 2, 2021

However for other users, such as those who want to install using emsdk, this is a new requirement and emsdk
currently pins CMAKE_OSX_DEPLOYMENT_TARGET to 10.11:

I think this should be "those who want to build using emsdk". Those who just install are using the Chromium builds and are unaffected.

I don't think that is how CMAKE_OSX_DEPLOYMENT_TARGET works. CMAKE_OSX_DEPLOYMENT_TARGET chooses the target macOS version that one will use to run the resulting output executable. So if Chromium builds are setting e.g. CMAKE_OSX_DEPLOYMENT_TARGET=10.14 when they build, then that does mean that people on macOS < 10.14 will not be (guaranteed to) be able to run the Chromium built artifacts.

E.g. in LLVM case, I recall if LLVM was built with CMAKE_OSX_DEPLOYMENT_TARGET = 10.14, then on macOS 10.13 it will fail to start clang executable with the symbol futimens not being found in the system dylibs, due to build time CMake lookup taking some alias that of that function differently since it was assuming that Xcode dylibs 10.14 would be available on the target machine.

@sbc100
Copy link
Member Author

sbc100 commented Nov 2, 2021

However for other users, such as those who want to install using emsdk, this is a new requirement and emsdk
currently pins CMAKE_OSX_DEPLOYMENT_TARGET to 10.11:

I think this should be "those who want to build using emsdk". Those who just install are using the Chromium builds and are unaffected.

I don't think that is how CMAKE_OSX_DEPLOYMENT_TARGET works. CMAKE_OSX_DEPLOYMENT_TARGET chooses the target macOS version that one will use to run the resulting output executable. So if Chromium builds are setting e.g. CMAKE_OSX_DEPLOYMENT_TARGET=10.14 when they build, then that does mean that people on macOS < 10.14 will not be (guaranteed to) be able to run the Chromium built artifacts.

E.g. in LLVM case, I recall if LLVM was built with CMAKE_OSX_DEPLOYMENT_TARGET = 10.14, then on macOS 10.13 it will fail to start clang executable with the symbol futimens not being found in the system dylibs, due to build time CMake lookup taking some alias that of that function differently since it was assuming that Xcode dylibs 10.14 would be available on the target machine.

The emscripten-releases builder that builds the emsdk binaries sets CMAKE_OSX_DEPLOYMENT_TARGET=10.12. It is able to do so because it bundles its own copy of libc++ so it does suffer from the problem discussed in this issue.

Thus the official binaries are not effect by this issue, only those using emsdk (or other build scripts) to build from source.

@sbc100
Copy link
Member Author

sbc100 commented Nov 2, 2021

@tlively / @kripken would you have time to look at this soon(ish).. would be nice to get this fixed ASAP to avoid breaking unity releases.

@kripken
Copy link
Member

kripken commented Nov 2, 2021

@sbc100 Sorry, I'm not sure what you're asking here. I saw various PRs related to this land - is there more work we need to do after those, and if so, what is it?

@sbc100
Copy link
Member Author

sbc100 commented Nov 2, 2021

We need to reduce this back to 10.11 (or 10.13 I guess). To do this we will probably need to implement the workaround suggest by @dschuff in #4299 (comment) or use std::get_if as suggest by @tlively in #4299 (comment).

Setting CMAKE_OSX_DEPLOYMENT_TARGET=10.13 in CMakeLists.txt should be enough to cause the build to fail so we easily verify that that fix actually does work.

@dschuff
Copy link
Member

dschuff commented Nov 2, 2021

The emscripten-releases builder that builds the emsdk binaries sets CMAKE_OSX_DEPLOYMENT_TARGET=10.12. It is able to do so because it bundles its own copy of libc++ so it does suffer from the problem discussed in this issue.

Thus the official binaries are not effect by this issue, only those using emsdk (or other build scripts) to build from source.

I just wanted to reiterate this. It's not actually that hard to build your own libc++ and link it into your own program such as Binaryen, especially if you do it statically.
Doing this is a little extra work setting up the build scripts, but it makes everything else optimal. You can target really old MacOS versions (we do 10.12), and you can use any C++ library features you want, without worrying about what library bugs might be present on those old OS versions. The reason we set this up for emscripten-releases is that we thought those benefits outweighed the costs. That was before this particular issue surfaced, but I'm actually not quite convinced that it changes the calculation. If we roll back to 10.13 we'll be limited to some subset of the standard library (we don't actually know yet how limited it will be, there could be other things missing besides get and visit).
I think this might still be a good tradeoff. @juj do you just use the emsdk scripts straight off the shelf to build? I'd be willing to help with making those work if it means we can keep using all of C++17.

@juj
Copy link
Collaborator

juj commented Nov 3, 2021

@juj do you just use the emsdk scripts straight off the shelf to build?

Yes, we basically run emsdk install sdk-upstream-master-64bit and package up the artifacts that result. If a custom libc++ resolves the issue, then that sounds an ok workaround, though then it would be great to be integrated to emsdk install step out of the box, without needing a custom side by side configuration set up?

@dschuff
Copy link
Member

dschuff commented Nov 3, 2021

I don't suppose just using our binaries directly would be an option for you?

@sbc100
Copy link
Member Author

sbc100 commented Nov 3, 2021

I think we need to keep the build-from-source option around, not least to support folks who can't use our pre-built binaries (e.g. non-glibc-based distros, or architectures we don't pre-build for).

@juj
Copy link
Collaborator

juj commented Jan 12, 2022

Maybe the way forward here would be to bundle the same libstdc++ into emsdk that is required by binaryen?

Currently it looks like emsdk install sdk-upstream-master-64bit is broken in emsdk even for up to date macOS, because of the conflicting MACOSX_DEPLOYMENT_TARGET directives.

@dschuff
Copy link
Member

dschuff commented Jan 12, 2022

That would work, yeah. In theory I think it ought to be sufficient to just statically link libc++ into Binaryen (since the problem comes from the fact that the libc++ on the old systems is missing stuff). But the error happens at compile time and can't take that into account. I wonder if there's a way to work around that, that would be easier than working from a local build or install of libc++ with its own headers...

lewing added a commit to dotnet/emsdk that referenced this issue Jan 28, 2022
* Improve emscripten-releases-tags.txt to support mutliple aliases (#837)

Also, improve reporting of version resolution. e.g.:

```
$ ./emsdk  install sdk-latest
Resolving SDK alias 'latest' to '2.0.23'
Resolving SDK version '2.0.23' to 'sdk-releases-upstream-77b065ace39e6ab21446e13f92897f956c80476a-64bit'
Installing SDK 'sdk-releases-upstream-77b065ace39e6ab21446e13f92897f956c80476a-64bit'..
...
```

* bugfix: allow to install SDK binaries alone (#834)

* 2.0.24 (#839)

* Error out on attempt to activate a missing tools (#838)

Previously if a tool (any part of an SDK) was not installed
we would issue a warning and continue to active without returning
non-zero.

This meant doing `emsdk install 2.0.0 && emsdk activate latest`
would appear to be work aside from the warning messages about
latest not being installed.

This is especially annoying since we dropped support for side
by side SDK installations.  The following sequence is no longer
valid and we want to make that clear by erroring out:

```
$ emsdk install 2.0.1
$ emsdk install 2.0.2
$ emsdk activate 2.0.1
```

Since 2.0.2 replaces 2.0.1 on the filesystem the active here
could fail hard rather than just warning.

* Consistent error messages (#840)

* Point zsh and csh users to the correct startup script (#843)

Fixes: emscripten-core/emscripten#14446

* Print sys.argv when link_wrapper.py is invoked incorrectly (#847)

This should help debug cases when the link_wrapper is not invoked correctly.

* Support linking with `-o filename` (#849)

When linking with `-o filename` (such as in various CMake build checks), the parameter passed to the linker is a temporary file, and it is passed as a bare filename (i.e. relative path without a `'/'`). In such cases, `outdir` would have been the empty string, and the final `tar` command would fail (actually the call to `subprocess.check_call(…)` is what fails).

* 2.0.25 (#850)

* 2.0.26 (#858)

* 2.0.26-lto (#861)

* 2.0.27 (#868)

Includes LTO and non-LTO, with non-LTO as the default

* 2.0.28 (#871)

* Use `.json` extension for emscripten-releases-tags.json. NFC (#870)

* Add LTO build for 2.0.28 (#873)

* Small fix for Bazel instructions. (#875)

In the past the instructions were to copy `emscripten_toolchain` into the project dir, now it downloads emsdk as a package so the `bazelrc` part has to refer to `@emsdk`.

* Version 2.0.29 (#878)

* 2.0.29-lto (#881)

* Fix release name for 2.0.29-lto (#885)

Fixes #884

* [Bazel] fix llvm bin path (#888)

* Add arm64 fastcomp releases to emsdk_manifest.json (#891)

This was missing from emsdk_manifest.json and should alow older fastcomp
SDKs to be install on M1 apple hardware (in emulation mode).

Fixes: #889

* 2.0.30 (#893)

* Fix error handling: untargz() in emsdk.py (#895)

Make untargz() in emsdk.py return False if tar command failed.

* Fix passing -DLLVM_ENABLE_PROJECTS directive to CMake - it does not want to see double quotes in the field passed to it. (#898)

* Fix emscripten-version parsing (#902)

See emscripten-core/emscripten#15144

* 2.0.31 (#906)

* bazel: pass -g instead of -g4 for wasm_asan feature (#904)

* Add embind example to Bazel docs (#910)

* Add embind example to Bazel docs

* address feedback

* Run buildifier on bazel/ (#913)

* Update build_bazel_rules_nodejs to fix closure compiles (#912)

* Update build_bazel_rules_nodejs to fix closure compiles

* Fix spacing in update_bazel_workspace.sh script

* space

* 2.0.32 (#915)

* Improve flags in bazel example (#917)

* Add back node.js 12.18.1 packages for Windows 7 support. (#877)

* Update CMAKE_OSX_DEPLOYMENT_TARGET from 10.11 to 10.14 (#924)

Apparently 10.11 is no longer good enough to run the latest version of
binaryen.  Specifically since binaryen switched to using std::variant it
now fails to build with this set to 10.11.

This is also the version used on the emscripten-releases CI which builds
the emsdk binaries:
https://chromium.googlesource.com/emscripten-releases/+/refs/heads/main/src/build.py#673

* Revert "Update CMAKE_OSX_DEPLOYMENT_TARGET from 10.11 to 10.14 (#924)"

This reverts commit 99e5e02.

* 2.0.33 (#922)

I add to temporarily disable the test_binaryen_from_source test
under macOS to work around:
WebAssembly/binaryen#4299

* 2.0.34 (#925)

* Bump EmscriptenVersion to 2.0.34

* Fix bad edit

Co-authored-by: Sam Clegg <sbc@chromium.org>
Co-authored-by: Yulong Wang <yulong.fs@gmail.com>
Co-authored-by: Attila Oláh <attilaolah@gmail.com>
Co-authored-by: Attila Oláh <atl@google.com>
Co-authored-by: Derek Schuff <dschuff@chromium.org>
Co-authored-by: Danny B <danila.bespalov@gmail.com>
Co-authored-by: Brad Kotsopoulos <bkotsopoulos@snapchat.com>
Co-authored-by: Matt Gucci <matt9ucci@gmail.com>
Co-authored-by: juj <jujjyl@gmail.com>
Co-authored-by: walkingeyerobot <mitch@thefoley.net>
Co-authored-by: Kevin Lubick <kjlubick@users.noreply.github.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
juj added a commit to emscripten-core/emsdk that referenced this issue Mar 4, 2022
@juj
Copy link
Collaborator

juj commented Mar 22, 2022

This is no longer a relevant issue to Unity, as Unity 2022.2 will target macOS 10.14 as minimum.

Though next time that minimum macOS is due to get bumped, I hope that it won't happen as "accidentally" as this bump from 10.11 to 10.14 occurred, but instead it will be caught on the CIs. It would be good to have the waterfall builds be the same as the end user builds, so that when the waterfall builds, it will produce the same output as end users do.

@dschuff
Copy link
Member

dschuff commented Mar 22, 2022

Thanks for the update, and sorry I haven't gotten to this. I don't think it's possible to run the bots on such an old version of MacOS, but I agree that we shouldn't update deployment targets without agreement (and one thing that went wrong here was that I didn't realize the emsdk build couldn't match the waterfall build).

@sbc100
Copy link
Member Author

sbc100 commented Mar 22, 2022

Now that we don't need to support 10.11.. can we revert back to using system libc++ (like the emsdk does). Seems like it would make the waterfall build simpler and easier to replicate if we didn't need to build libc++ first!

@sbc100
Copy link
Member Author

sbc100 commented Mar 22, 2022

i.e. not building our own libc++ would actually bring the two builders back into parity which would address @juj's concern (the emscripten-releases waterfall would not be able to feature creep).

@dschuff
Copy link
Member

dschuff commented Mar 22, 2022

We could. Right now emscripten-releases actually targets 10.12, which goes back to the first time the build was checked in, so I don't really know exactly why we had that version in particular. If we want to require 10.14, according to https://gs.statcounter.com/macos-version-market-share/desktop/worldwide that would cover just about 90% of all installs. So if you figure developers are a bit more likely to be up-to-date than the average user, that probably gets about everyone?

@sbc100
Copy link
Member Author

sbc100 commented Mar 22, 2022

Lets go for 10.14 to stay in sync with unity and emsdk and binaryen itself (when building without custom libc++)

@juj
Copy link
Collaborator

juj commented Mar 22, 2022

I don't think it's possible to run the bots on such an old version of MacOS

There is no need to install an old macOS to target old OS versions. That is what CMAKE_OSX_DEPLOYMENT_TARGET is for. For example, we also use modern macOS 11 or 12 to build, but pass CMAKE_OSX_DEPLOYMENT_TARGET=10.14 to require that the build is targeting that version as minimum.

i.e. not building our own libc++ would actually bring the two builders back into parity

That would be great!

juj added a commit to emscripten-core/emsdk that referenced this issue Mar 23, 2022
* Fix macOS build. See WebAssembly/binaryen#4299

* Update comment
@dschuff
Copy link
Member

dschuff commented Mar 24, 2022

Sorry, I meant I don't know of a good way to test on the bots (i.e. make a test that fails when we build with the wrong deployment target).
But since we already explicitly specify the deployment target in the build script, and as of yesterday the Chromium emscripten-releases build is in sync with emsdk (and there's a comment to remind us that we should keep them in sync), we are at least in the position where a change to that would be caught by review. So I think we are in pretty good shape now.

@dschuff dschuff closed this as completed Mar 24, 2022
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

5 participants