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

Build static library for JavaScriptCore before linking framework #19575

Conversation

ddkilzer
Copy link
Contributor

@ddkilzer ddkilzer commented Oct 26, 2023

3d73290

Build static library for JavaScriptCore before linking framework
https://bugs.webkit.org/show_bug.cgi?id=263697
<rdar://113641596>

Reviewed by Elliott Williams.

This change introduces a libJavaScriptCore.a target, which is then used
to link JavaScriptCore.framework.  By configuring the project to build
this way, there is no need to duplicate the list of sources between both
targets.  When JSC_USE_STATIC_LINKING=YES, the jsc binary is linked to
libJavaScriptCore.a instead of to JavaScriptCore.framework.

* Source/JavaScriptCore/API/JSWrapperMap.h:
* Source/JavaScriptCore/API/ObjCCallbackFunction.h:
- Fix header include paths to work with static library.
* Source/JavaScriptCore/Configurations/BaseTarget.xcconfig: Copy from Source/JavaScriptCore/Configurations/JSC.xcconfig.
- Extract common variables from JavaScriptCore.xcconfig that are shared
  with libJavaScriptCore.xcconfig.
* Source/JavaScriptCore/Configurations/Base.xcconfig:
- Extract linker variables from JavaScriptCore.xcconfig that are shared
  with JSC.xcconfig.
- Note that `-fobjc-link-runtime` replaces
  `-lobjc -framework CoreFoundation -framework Foundation`.
* Source/JavaScriptCore/Configurations/JSC.xcconfig:
(JSC_USE_STATIC_LINKING): Add.
- Set to the same boolean value as ENABLE_LIBFUZZER (which will default
  to NO), but make it a separate variable to allow this behavior to be
  overriden via xcodebuild.
- Configure OTHER_LDFLAGS to statically link libJavaScriptCore.a when
  JSC_USE_STATIC_LINKING=YES, else use dynamic linking (default) to
  JavaScriptCore.framework.
* Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig:
- Extract shared variables into BaseTarget.xcconfig.
- Move build related variables into libJavaScriptCore.xcconfig.
* Source/JavaScriptCore/Configurations/libJavaScriptCore.xcconfig: Add.
- Move build-related variables from JavaScriptCore.xcconfig.
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
- Add new xcconfig files to project.
- Add libJavaScriptCore.a target and use libJavaScriptCore.xcconfig as
  its base.
- Move from JavaScriptCore framework target to libJavaScriptCore target:
  - Custom Build Rules.
  - Compile Sources.
  - Target Dependencies.
  - Copy Profiling Data build phase script.
- Add target dependency on libJavaScriptCore to JavaScriptCore.
- Add JavaScriptCoreFramework.cpp source file to JavaScriptCore
  framework target.
- Remove all items from "Link Binary with Libraries" for JavaScriptCore
  and jsc targets (except libedit.dylib on jsc) since this is handled
  via OTHER_LDFLAGS in xcconfig files now.
* Source/JavaScriptCore/JavaScriptCoreFramework.cpp: Add.
- Xcode requires at least one source file to compile to link a
  framework so create an empty one.

Canonical link: https://commits.webkit.org/270226@main

999fdfb

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  πŸ§ͺ jsc βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ jsc-arm64 βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ›  jsc-armv7
βœ… πŸ›  tv-sim βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  watch βœ… πŸ›  jsc-mips
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@ddkilzer ddkilzer requested a review from a team as a code owner October 26, 2023 00:43
@ddkilzer ddkilzer self-assigned this Oct 26, 2023
@ddkilzer ddkilzer added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Oct 26, 2023
@ddkilzer ddkilzer force-pushed the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch from 4ddd321 to 52c04d1 Compare October 26, 2023 01:43
@emw-apple emw-apple self-requested a review October 26, 2023 02:04
@ddkilzer ddkilzer force-pushed the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch from 52c04d1 to 11c3a5b Compare October 26, 2023 02:14
@ddkilzer ddkilzer requested review from emw-apple and removed request for kmiller68 October 26, 2023 03:08
@ddkilzer ddkilzer force-pushed the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch from 11c3a5b to 8478aa3 Compare October 30, 2023 17:15
@ddkilzer
Copy link
Contributor Author

Updated PR to include feedback from @emw-apple.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 30, 2023
Copy link
Contributor

@emw-apple emw-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ with a couple fixups. Looks great!

Source/JavaScriptCore/API/JSWrapperMap.h Outdated Show resolved Hide resolved
@ddkilzer ddkilzer removed the merging-blocked Applied to prevent a change from being merged label Nov 4, 2023
@ddkilzer ddkilzer force-pushed the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch from 8478aa3 to 999fdfb Compare November 4, 2023 03:36
@ddkilzer ddkilzer added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 4, 2023
https://bugs.webkit.org/show_bug.cgi?id=263697
<rdar://113641596>

Reviewed by Elliott Williams.

This change introduces a libJavaScriptCore.a target, which is then used
to link JavaScriptCore.framework.  By configuring the project to build
this way, there is no need to duplicate the list of sources between both
targets.  When JSC_USE_STATIC_LINKING=YES, the jsc binary is linked to
libJavaScriptCore.a instead of to JavaScriptCore.framework.

* Source/JavaScriptCore/API/JSWrapperMap.h:
* Source/JavaScriptCore/API/ObjCCallbackFunction.h:
- Fix header include paths to work with static library.
* Source/JavaScriptCore/Configurations/BaseTarget.xcconfig: Copy from Source/JavaScriptCore/Configurations/JSC.xcconfig.
- Extract common variables from JavaScriptCore.xcconfig that are shared
  with libJavaScriptCore.xcconfig.
* Source/JavaScriptCore/Configurations/Base.xcconfig:
- Extract linker variables from JavaScriptCore.xcconfig that are shared
  with JSC.xcconfig.
- Note that `-fobjc-link-runtime` replaces
  `-lobjc -framework CoreFoundation -framework Foundation`.
* Source/JavaScriptCore/Configurations/JSC.xcconfig:
(JSC_USE_STATIC_LINKING): Add.
- Set to the same boolean value as ENABLE_LIBFUZZER (which will default
  to NO), but make it a separate variable to allow this behavior to be
  overriden via xcodebuild.
- Configure OTHER_LDFLAGS to statically link libJavaScriptCore.a when
  JSC_USE_STATIC_LINKING=YES, else use dynamic linking (default) to
  JavaScriptCore.framework.
* Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig:
- Extract shared variables into BaseTarget.xcconfig.
- Move build related variables into libJavaScriptCore.xcconfig.
* Source/JavaScriptCore/Configurations/libJavaScriptCore.xcconfig: Add.
- Move build-related variables from JavaScriptCore.xcconfig.
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
- Add new xcconfig files to project.
- Add libJavaScriptCore.a target and use libJavaScriptCore.xcconfig as
  its base.
- Move from JavaScriptCore framework target to libJavaScriptCore target:
  - Custom Build Rules.
  - Compile Sources.
  - Target Dependencies.
  - Copy Profiling Data build phase script.
- Add target dependency on libJavaScriptCore to JavaScriptCore.
- Add JavaScriptCoreFramework.cpp source file to JavaScriptCore
  framework target.
- Remove all items from "Link Binary with Libraries" for JavaScriptCore
  and jsc targets (except libedit.dylib on jsc) since this is handled
  via OTHER_LDFLAGS in xcconfig files now.
* Source/JavaScriptCore/JavaScriptCoreFramework.cpp: Add.
- Xcode requires at least one source file to compile to link a
  framework so create an empty one.

Canonical link: https://commits.webkit.org/270226@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch from 999fdfb to 3d73290 Compare November 4, 2023 10:26
@webkit-commit-queue
Copy link
Collaborator

Committed 270226@main (3d73290): https://commits.webkit.org/270226@main

Reviewed commits have been landed. Closing PR #19575 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 3d73290 into WebKit:main Nov 4, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 4, 2023
@ddkilzer ddkilzer deleted the eng/Build-static-library-for-JavaScriptCore-before-linking-framework branch November 4, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.
Projects
None yet
6 participants