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

Fix klayout build on macos #298

Merged
merged 2 commits into from
Feb 25, 2023
Merged

Fix klayout build on macos #298

merged 2 commits into from
Feb 25, 2023

Conversation

xobs
Copy link
Contributor

@xobs xobs commented Feb 18, 2023

This fixes the klayout package so that it now builds properly on osx-arm64.

@xobs
Copy link
Contributor Author

xobs commented Feb 18, 2023

Note that I'm not sure why build/pymod/*.dylib isn't copied over to bin-release/pymod/, but it seems to be copied on the Linux version. So I added the final cp for only that platform.

@proppy
Copy link
Contributor

proppy commented Feb 18, 2023

Note that I'm not sure why build/pymod/*.dylib isn't copied over to bin-release/pymod/, but it seems to be copied on the Linux version. So I added the final cp for only that platform.

Maybe @klayoutmatthias as a clue?

misc/klayout/build.sh Outdated Show resolved Hide resolved
@xobs
Copy link
Contributor Author

xobs commented Feb 18, 2023

I added a symlink to klayout, which allows it to be used from the command line.

.github/workflows/Build.yml Outdated Show resolved Hide resolved
@proppy
Copy link
Contributor

proppy commented Feb 18, 2023

Looks like the osx build failed with:

2023-02-18T11:44:41.6904360Z ld: warning: -pie being ignored. It is only used when linking a main executable
2023-02-18T11:44:41.7225230Z ld: in '/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks//ColorSync.framework/Versions/A/ColorSync.tbd', unsupported tapi file type '!tapi-tbd' in YAML for architecture x86_64
2023-02-18T11:44:41.7241560Z clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
2023-02-18T11:44:41.7265570Z make[2]: *** [Makefile:384: ../../tl/libtl_tests.0.28.5.dylib] Error 1
2023-02-18T11:44:41.7284780Z make[1]: *** [Makefile:76: sub-unit_tests-make_first] Error 2
2023-02-18T11:44:41.7296980Z make: *** [Makefile:74: sub-tl-make_first] Error 2

@xobs
Copy link
Contributor Author

xobs commented Feb 19, 2023

Conda seems to be adding -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.15 on my local build, and I can't figure out where that's coming from.

What's even more annoying is that the environment doesn't seem to have those variables anywhere. If I modify build.sh to use the correct values, it appears twice:

    export CXXFLAGS="${CXXFLAGS} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -D_LIBCPP_DISABLE_AVAILABILITY -isysroot ${CONDA_BUILD_SYSROOT}"
    export CFLAGS="${CFLAGS} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -D_LIBCPP_DISABLE_AVAILABILITY -isysroot ${CONDA_BUILD_SYSROOT}"

becomes:

...
-mmacosx-version-min=11.0 \
-D_LIBCPP_DISABLE_AVAILABILITY \
-isysroot /Users/sean/Code/EDA/sdk/MacOSX10.9.sdk \
-std=c++17 \
-fvisibility=hidden \
-std=c++17 \
-fvisibility=hidden \
-std=gnu++1z \
$(EXPORT_ARCH_ARGS) \
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
-mmacosx-version-min=10.15
...

@xobs
Copy link
Contributor Author

xobs commented Feb 19, 2023

...also, I'm not sure where it's getting MACOSX_DEPLOYMENT_TARGET=10.15 or MACOSX_DEPLOYMENT_TARGET=11.0 from. Both ci/conda_build.config.yaml and the build environment set MACOSX_DEPLOYMENT_TARGET=10.9, and that's what Conda seems to imply is the default:

https://docs.conda.io/projects/conda-build/en/latest/user-guide/environment-variables.html#env-vars

@klayoutmatthias
Copy link

Note that I'm not sure why build/pymod/*.dylib isn't copied over to bin-release/pymod/, but it seems to be copied on the Linux version. So I added the final cp for only that platform.

Maybe @klayoutmatthias as a clue?

Honestly, I have never tested pymod generation on MacOS. Mainly because MacOS is not my home turf. The installation basically is generic, but maybe it needs to be specialized for MacOS.

@xobs
Copy link
Contributor Author

xobs commented Feb 20, 2023

I discovered that Qt ignores standard CFLAGS and CXXFLAGS and instead uses its own QMAKE_CFLAGS and QMAKE_CXXFLAGS.

I also discovered that MacOS 11.0 was the first version that supported arm64, so I bumped the minimum version up to that.

Note that 10.11 is the first version that supported Metal, so we would need to use that at a minimum in order to get support for klayout.

Additionally, it looks like it might be possible to build osx-arm64 from osx-x86_64 as documented at https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/ -- note that they also build for macos 11.0 in there.

@proppy
Copy link
Contributor

proppy commented Feb 21, 2023

Additionally, it looks like it might be possible to build osx-arm64 from osx-x86_64 as documented at https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/ -- note that they also build for macos 11.0 in there.

Filed #299 to discuss arm64 builds.

@xobs xobs force-pushed the klayout-macos branch 2 times, most recently from 77bb76b to 0ab9ad9 Compare February 23, 2023 13:17
@xobs xobs force-pushed the klayout-macos branch 2 times, most recently from 3b53d09 to 5dc7d28 Compare February 23, 2023 13:25
@xobs
Copy link
Contributor Author

xobs commented Feb 23, 2023

It builds and passes tests! \o/

xobs added 2 commits February 24, 2023 11:13
Signed-off-by: Sean Cross <[email protected]>
Add support for klayout to build on macos. This involves some rather
egregeous hacks to the Qt build system to work around the fact that
Conda builds things using a custom Mac SDK.

Signed-off-by: Sean Cross <[email protected]>
@proppy
Copy link
Contributor

proppy commented Feb 24, 2023

Looks like python3.10 job is failing when trying to install python >= 3.10 as a host dep from conda running on python 3.7.

@xobs
Copy link
Contributor Author

xobs commented Feb 25, 2023

I'll just remove that, then...

@proppy
Copy link
Contributor

proppy commented Feb 25, 2023

Merging since both jobs passes (not sure if we want to suffix the job with -python38 for consistency).

@proppy proppy merged commit 0ff90c1 into hdl:master Feb 25, 2023
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 this pull request may close these issues.

3 participants