apache / couchdb

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability
https://couchdb.apache.org/
Apache License 2.0
6.28k stars 1.03k forks source link

dev(windows): Compile error on Windows (SpiderMonkey 102-128) #5322

Open big-r81 opened 1 month ago

big-r81 commented 1 month ago

Description

Trying to compile CouchDB with SpiderMonkey 128 (102, 115) on Windows. I used the provided SM binaries from https://github.com/big-r81/couchdb-sm/releases/tag/v0.0.7

We get many compiler warnings from the Mozilla sources and some errors too (Full log: mozjs128.txt).

For example:

C:\tools\Windows-mozjs-128\include\jspubtd.h(88): error C2146: syntax error: missing '}' before identifier 'JSProto_LIMIT'
C:\tools\Windows-mozjs-128\include\jspubtd.h(89): error C2143: syntax error: missing ';' before '}'
C:\tools\Windows-mozjs-128\include\jspubtd.h(89): error C2059: syntax error: '}'

Opening jspubtd.h shows the following:

83  /* Dense index into cached prototypes and class atoms for standard objects. */
84  enum JSProtoKey {
85  #define PROTOKEY_AND_INITIALIZER(name, clasp) JSProto_##name,
86    JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER)
87  #undef PROTOKEY_AND_INITIALIZER
88        JSProto_LIMIT
89  };

or

C:\tools\Windows-mozjs-128\include\js/Class.h(589): error C2131: expression did not evaluate to a constant
C:\tools\Windows-mozjs-128\include\js/Class.h(589): note: failure was caused by non-constant arguments or reference to a non-constant symbol
C:\tools\Windows-mozjs-128\include\js/Class.h(589): note: see usage of 'JSProto_LIMIT'

Class.h:

589  static_assert(JSProto_LIMIT <= (JSCLASS_CACHED_PROTO_MASK + 1),
590                "JSProtoKey must not exceed the maximum cacheable proto-mask");

or

C:\tools\Windows-mozjs-128\include\js/Symbol.h(74): error C2146: syntax error: missing '}' before identifier 'Limit'
C:\tools\Windows-mozjs-128\include\js/Symbol.h(75): error C2440: 'initializing': cannot convert from 'const uint32_t' to 'JS::SymbolCode'
C:\tools\Windows-mozjs-128\include\js/Symbol.h(75): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast)
C:\tools\Windows-mozjs-128\include\js/Symbol.h(76): error C2440: 'initializing': cannot convert from 'unsigned int' to 'JS::SymbolCode'
C:\tools\Windows-mozjs-128\include\js/Symbol.h(76): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast)
C:\tools\Windows-mozjs-128\include\js/Symbol.h(77): error C2440: 'initializing': cannot convert from 'unsigned int' to 'JS::SymbolCode'
C:\tools\Windows-mozjs-128\include\js/Symbol.h(77): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast)
C:\tools\Windows-mozjs-128\include\js/Symbol.h(79): error C2440: 'initializing': cannot convert from 'unsigned int' to 'JS::SymbolCode'
C:\tools\Windows-mozjs-128\include\js/Symbol.h(79): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast)
C:\tools\Windows-mozjs-128\include\js/Symbol.h(80): error C2143: syntax error: missing ';' before '}'

Symbol.h:

68  enum class SymbolCode : uint32_t {
69  // There is one SymbolCode for each well-known symbol.
70  #define JS_DEFINE_SYMBOL_ENUM(name) name,
71    JS_FOR_EACH_WELL_KNOWN_SYMBOL(
72        JS_DEFINE_SYMBOL_ENUM)  // SymbolCode::iterator, etc.
73  #undef JS_DEFINE_SYMBOL_ENUM
74    Limit,
75    WellKnownAPILimit = JS::shadow::Symbol::WellKnownAPILimit,
76    PrivateNameSymbol = 0xfffffffd,  // created by the #PrivateName syntax.
77    InSymbolRegistry =
78        0xfffffffe,            // created by Symbol.for() or JS::GetSymbolFor()
79    UniqueSymbol = 0xffffffff  // created by Symbol() or JS::NewSymbol()
80  };

A complete list of warnings and errors are in the full log: mozjs128.txt

My first idea is, that it maybe has something to do with the Microsoft compiler cl.exe or maybe a C++ standard? Maybe the compiler switch get not recognized by rebar from the script?

Steps to Reproduce

  1. All happens on Windows
  2. Checkout couchdb with the branch jenkins-simplify-spidermonkeys
  3. Checkout couchdb-glazier
  4. Download Windows-mozjs-128
  5. Add it to the $env:{PATH,LIB,INCLUDE,LIBPATH} environment variables in couchdb-glazier/bin/shell.ps1
  6. Open Powershell and call shell.ps1
  7. CD into the couchdb source directory
  8. Run .\configure.ps1 -SpiderMonkeyVersion 128 -DisableDocs -DisableFauxton
  9. Run .\make.cmd
  10. See the errors from above

A did a quick test for SpiderMonkey v102 too and the problems are similar!

Maybe @nickva and @pgj can have a look and try to reproduce this?