Embedding with SpiderMonkey 128.x fails on Visual Studio due to __has_attribute
Categories
(Core :: MFBT, defect)
Tracking
()
People
(Reporter: fanc999, Assigned: mgaudet)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
1.37 KB,
text/plain
|
Details | |
48 bytes,
text/x-phabricator-request
|
dmeehan
:
approval-mozilla-esr128+
|
Details | Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Steps to reproduce:
Using the latest Visual Studio 2019 (along with Rust, clang-cl for building SpiderMonkey):
- Build and install Spidermonkey 128.0 from Firefox-128.0/Firefox 128.0ESR, using mozilla-build.
- Install the Meson build system.
- Build and install GLib, gobject-introspection and its dependencies.
- Checkout the mozjs128 branch of https://gitlab.gnome.org/ptomato/gjs.git, which is the repository for GJS (GNOME JavaScript engine) that is now being ported for SpiderMonkey 128.x.
- Using Visual Studio 2019, run 'meson setup %HOMEPATH%\gjs --buildtype=debugoptimized --prefix=c:/gnome.build.unstable/vs14/x64 -Dpkgconfig.relocatable=true -Dprofiler=disabled -Dskip_dbus_tests=true'
Actual results:
The Meson configuration fails with the following error:
meson.build:291:4: ERROR: Problem encountered: A minimal SpiderMonkey program
could not be compiled or linked. Most likely you should build it with a
Checking into the logs, an error occurred when including mozilla/Attributes.h
, where the error was: ...\mozjs-128\mozilla/Attributes.h(96): fatal error C1012: unmatched parenthesis: missing ')'
, and this points to using the defined(__clang__) && __has_attribute(...)
construct
Expected results:
The configuration (and build) should have succeeded
The workaround I had was to add the following before the first instance of the usage of defined(__clang__) && __has_attribute(...)
construct:
#if defined (_MSC_VER) && !defined (__clang__)
#define __has_attribute(attr) 0
#endif
Comment 2•9 months ago
|
||
To make diagnosis easier so you don't have to install and configure GJS, here's the "minimal program" that fails to compile with VS2019:
#include <js/Initialization.h>
int main(void) {
if (!JS_Init()) return 1;
JS_ShutDown();
return 0;
}
Assignee | ||
Updated•9 months ago
|
Assignee | ||
Comment 3•9 months ago
|
||
Officially we don't suppport building with MSVC since Firefox 63.
Unofficially, we may take a patch depending on how invasive it is.
Here's my proposed patch for mfbt/Attributes.h
.
With blessings, thank you!
(Please note that this is done with diff -u
since I don't have the repo cloned as my connection here isn't that great, so I don't have a commit message there)
Assignee | ||
Comment 6•9 months ago
|
||
Ok, I have create a patch and submitted it to try for testing; if that comes back clean then I will submit the patch on your behalf
https://treeherder.mozilla.org/jobs?repo=try&revision=5a557d878b677f75434b86e67d23bd96b54402dc
Assignee | ||
Comment 7•9 months ago
|
||
Note this patch was provided by a contributor to fix MSVC builds of a SpiderMonkey embedding.
Updated•9 months ago
|
(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #7)
Created attachment 9413320 [details]
Bug 1907001 - Add MOZ_HAS_CLANG_ATTRIBUTE r?#firefox-build-system-reviewersNote this patch was provided by a contributor to fix MSVC builds of a SpiderMonkey embedding.
Thanks a bunch! Sorry, I was too used to the GNOME style (the space before the parens).
Updated•9 months ago
|
Updated•9 months ago
|
Comment 9•9 months ago
|
||
The component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit BugBot documentation.
Comment 10•9 months ago
|
||
Comment 11•9 months ago
|
||
bugherder |
Updated•9 months ago
|
Comment 12•9 months ago
|
||
Comment on attachment 9413320 [details]
Bug 1907001 - Add MOZ_HAS_CLANG_ATTRIBUTE r?glandium
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: Fixes build failure on MSVC.
- User impact if declined: Embedders cannot build SpiderMonkey using MSVC.
- Fix Landed on Version: 130
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Only touches preprocessor macros and only affects non-Clang builds. Any breakages caused by this patch would be expected to show up at compile time.
Comment 13•9 months ago
|
||
Comment on attachment 9413320 [details]
Bug 1907001 - Add MOZ_HAS_CLANG_ATTRIBUTE r?glandium
Approved for 128.2esr
Comment 14•9 months ago
|
||
uplift |
Updated•9 months ago
|
Description
•