Closed Bug 1706774 Opened 4 years ago Closed 3 years ago

Building `--enable-application=memory` fails on Windows

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(firefox-esr78 unaffected, firefox88 unaffected, firefox89 wontfix, firefox90 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox88 --- unaffected
firefox89 --- wontfix
firefox90 --- fixed

People

(Reporter: nalexander, Assigned: mhentges)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

No longer can I build --enable-application=memory on Windows. After fixing up some broken includes and other small nits with:

diff --git a/mfbt/moz.build b/mfbt/moz.build
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -171,16 +171,29 @@ UNIFIED_SOURCES += [
 
 if CONFIG["MOZ_BUILD_APP"] not in (
     "memory",
     "tools/update-programs",
 ):
     # Building MFBT tests adds a large overhead when building.
     TEST_DIRS += ["tests"]
 
+if CONFIG["MOZ_BUILD_APP"] == "memory":
+    EXPORTS.mozilla += [
+        "/mozglue/misc/IntegerPrintfMacros.h",
+        "/mozglue/misc/Sprintf.h",
+    ]
+
+    if CONFIG["OS_ARCH"] == "WINNT":
+        EXPORTS.mozilla += [
+            "/mozglue/misc/StackWalk_windows.h",
+            "/mozglue/misc/StackWalkThread.h",
+        ]
+
+
 DEFINES["IMPL_MFBT"] = True
 
 SOURCES += [
     "lz4/lz4.c",
     "lz4/lz4frame.c",
     "lz4/lz4hc.c",
     "lz4/xxhash.c",
 ]
diff --git a/moz.configure b/moz.configure
--- a/moz.configure
+++ b/moz.configure
@@ -601,17 +601,21 @@ def build_backend_defaults(
         all_backends = []
     elif artifact_builds:
         all_backends = ["FasterMake+RecursiveMake"]
     else:
         all_backends = ["RecursiveMake", "FasterMake"]
     # Normally, we'd use target.os == 'WINNT', but a dependency on target
     # would require target to depend on --help, as well as host and shell,
     # and this is not a can of worms we can open at the moment.
-    if sys.platform == "win32" and compile_environment and project != "mobile/android":
+    if (
+        sys.platform == "win32"
+        and compile_environment
+        and project not in ("mobile/android", "memory")
+    ):
         all_backends.append("VisualStudio")
     return tuple(all_backends) or None
 
 
 option(
     "--build-backends",
     nargs="+",
     default=build_backend_defaults,

I get errors like:

$ ./mach build
 0:02.12 Clobber not needed.
 0:02.14 Adding make options from c:\Users\nalexander\Mozilla\mozconfig-gecko-win64
    AUTOCLOBBER=1
    MOZ_OBJDIR=c:/Users/nalexander/Mozilla/objdirs/objdir-gecko-memory-win64
    OBJDIR=c:/Users/nalexander/Mozilla/objdirs/objdir-gecko-memory-win64
    FOUND_MOZCONFIG=c:/Users/nalexander/Mozilla/mozconfig-gecko-win64
    export FOUND_MOZCONFIG
 0:02.18 c:\mozilla-build\bin\mozmake.EXE -f client.mk -s
 0:02.67 Elapsed: 0.00s; From dist/public: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:02.67 Elapsed: 0.01s; From dist/private: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:02.79 Elapsed: 0.08s; From dist/bin: Kept 10 existing; Added/updated 16; Removed 0 files and 0 directories.
 0:02.81 Elapsed: 0.15s; From dist/include: Kept 0 existing; Added/updated 131; Removed 0 files and 0 directories.
 0:03.20 Elapsed: 0.54s; From _tests: Kept 0 existing; Added/updated 586; Removed 0 files and 0 directories.
 0:03.68 ./mozilla-config.h.stub
 0:03.69 ./buildid.h.stub
 0:03.69 ./source-repo.h.stub
 0:04.81 ./application.ini.stub
 0:04.81 ./stl.sentinel.stub
 0:04.81 ./windows.h.stub
 0:05.16 ./application.ini.h.stub
 0:05.70 memory/build
 0:05.71 build/win32
 0:05.71 build/win32/crashinjectdll
 0:05.71 memory/mozjemalloc_info
 0:05.72 memory/replace/phc
 0:05.72 mfbt
 0:05.72 memory/replace/logalloc
 0:05.72 memory/replace/logalloc/replay
 0:06.70 build/win32/crashinjectdll/crashinjectdll.dll
 0:06.79 build/win32/crashinject.exe
 0:07.04 memory/replace/logalloc/logalloc.dll
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(155,27): error: dllimport cannot be applied to non-inline function definition
 0:07.38 AutoSuppressStackWalking::AutoSuppressStackWalking() { SuppressStackWalking(); }
 0:07.38                           ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(158,27): error: dllimport cannot be applied to non-inline function definition
 0:07.38 AutoSuppressStackWalking::~AutoSuppressStackWalking() {
 0:07.38                           ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(167,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void RegisterJitCodeRegion(uint8_t* aStart, size_t aSize) {
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(175,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void UnregisterJitCodeRegion(uint8_t* aStart, size_t aSize) {
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(454,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void MozStackWalkThread(MozWalkStackCallback aCallback,
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(463,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void MozStackWalk(MozWalkStackCallback aCallback,
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(605,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API bool MozDescribeCodeAddress(void* aPC,
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(931,6): warning: 'mozilla::FramePointerStackWalk' redeclared without 'dllimport' attribute: 'dllexport' attribute added [-Winconsistent-dllimport]
 0:07.38 void FramePointerStackWalk(MozWalkStackCallback aCallback, uint32_t aMaxFrames,
 0:07.38      ^
 0:07.38 c:/Users/nalexander/Mozilla/objdirs/objdir-gecko-memory-win64/dist/include/mozilla/StackWalk.h(204,15): note: previous declaration is here
 0:07.38 MFBT_API void FramePointerStackWalk(MozWalkStackCallback aCallback,
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(952,14): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API int MozFormatCodeAddressDetails(
 0:07.38              ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(961,14): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API int MozFormatCodeAddress(char* aBuffer, uint32_t aBufferSize,
 0:07.38              ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(1038,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void MozWalkTheStack(FILE* aStream, const void* aFirstFramePC,
 0:07.38               ^
 0:07.38 c:/Users/nalexander/Mozilla/gecko/mozglue/misc/StackWalk.cpp(1054,15): error: dllimport cannot be applied to non-inline function definition
 0:07.38 MFBT_API void MozWalkTheStackWithWriter(void (*aWriter)(const char*),
 0:07.39               ^
 0:07.39 1 warning and 11 errors generated.
 0:07.39 mozmake.EXE[4]: *** [c:/Users/nalexander/Mozilla/gecko/config/rules.mk;674: StackWalk.obj] Error 1
 0:07.39 mozmake.EXE[4]: *** Waiting for unfinished jobs....
 0:07.70 mozmake.EXE[3]: *** [c:/Users/nalexander/Mozilla/gecko/config/recurse.mk;72: memory/replace/phc/target-objects] Error 2
 0:07.70 mozmake.EXE[3]: *** Waiting for unfinished jobs....
 0:09.08 In file included from Unified_cpp_memory_build0.cpp:2:
 0:09.09 c:/Users/nalexander/Mozilla/gecko/memory/build/mozjemalloc.cpp(1212,16): warning: unused function '_malloc_prefork' [-Wunused-function]
 0:09.09 FORK_HOOK void _malloc_prefork(void);
 0:09.09                ^
 0:09.09 c:/Users/nalexander/Mozilla/gecko/memory/build/mozjemalloc.cpp(1213,16): warning: unused function '_malloc_postfork_parent' [-Wunused-function]
 0:09.09 FORK_HOOK void _malloc_postfork_parent(void);
 0:09.09                ^
 0:09.09 c:/Users/nalexander/Mozilla/gecko/memory/build/mozjemalloc.cpp(1214,16): warning: unused function '_malloc_postfork_child' [-Wunused-function]
 0:09.09 FORK_HOOK void _malloc_postfork_child(void);
 0:09.09                ^
 0:09.09 3 warnings generated.
 0:09.99 mozmake.EXE[2]: *** [c:/Users/nalexander/Mozilla/gecko/config/recurse.mk;34: compile] Error 2
 0:10.00 mozmake.EXE[1]: *** [c:/Users/nalexander/Mozilla/gecko/config/rules.mk;355: default] Error 2
 0:10.00 mozmake.EXE: *** [client.mk;65: build] Error 2
 0:10.02 4 compiler warnings present.

I'm fairly sure that this is a regression from Bug 1699375.

:glandium: I tried to understand the details around internal and external visibility but couldn't deduce the magic incantation. Can you help?

Flags: needinfo?(mh+mozilla)

The Bugbug bot thinks this bug is a defect, but please change it back in case of error.

Type: enhancement → defect

Set release status flags based on info from the regressing bug 1699375

(In reply to Nick Alexander :nalexander [he/him] from comment #0)

No longer can I build --enable-application=memory on Windows. After fixing up some broken includes and other small nits with:

diff --git a/mfbt/moz.build b/mfbt/moz.build
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -171,16 +171,29 @@ UNIFIED_SOURCES += [
 
 if CONFIG["MOZ_BUILD_APP"] not in (
     "memory",
     "tools/update-programs",
 ):
     # Building MFBT tests adds a large overhead when building.
     TEST_DIRS += ["tests"]
 
+if CONFIG["MOZ_BUILD_APP"] == "memory":
+    EXPORTS.mozilla += [
+        "/mozglue/misc/IntegerPrintfMacros.h",
+        "/mozglue/misc/Sprintf.h",
+    ]
+
+    if CONFIG["OS_ARCH"] == "WINNT":
+        EXPORTS.mozilla += [
+            "/mozglue/misc/StackWalk_windows.h",
+            "/mozglue/misc/StackWalkThread.h",
+        ]
+
+

This should go in memory/app.mozbuild.

(In reply to Nick Alexander :nalexander [he/him] from comment #1)

:glandium: I tried to understand the details around internal and external visibility but couldn't deduce the magic incantation. Can you help?

The problem is that https://searchfox.org/mozilla-central/rev/37edd2782e67e716dd07a85016da07b4d6275e5d/memory/replace/dmd/moz.build#30 is missing in memory/replace/phc/moz.build.

Flags: needinfo?(mh+mozilla)
Priority: -- → P3
Assignee: nobody → mhentges
Status: NEW → ASSIGNED

I've applied Nick's patch and glandium's suggestion about IMPL_MFBT, but I'm running into the following issue:

 0:08.14 lld-link: error: undefined symbol: protected: __cdecl mozilla::PrintfTarget::PrintfTarget(void)
 0:08.14 >>> referenced by c:\dev\firefox-unified\obj-x86_64-pc-mingw32\dist\include\mozilla\Sprintf.h:84
 0:08.14 >>>               Assertions.obj:(int __cdecl VsprintfLiteral<1024>(char (&)[1024], char const *, char *))
 0:08.14 lld-link: error: undefined symbol: public: bool __cdecl mozilla::PrintfTarget::vprint(char const *, char *)
 0:08.14 >>> referenced by c:\dev\firefox-unified\obj-x86_64-pc-mingw32\dist\include\mozilla\Sprintf.h:84
 0:08.14 >>>               Assertions.obj:(int __cdecl VsprintfLiteral<1024>(char (&)[1024], char const *, char *))

I'll dig in, but pointers are welcome - I'm not familiar with the domain here.

(In reply to Mitchell Hentges [:mhentges] 🦀 from comment #5)

I've applied Nick's patch and glandium's suggestion about IMPL_MFBT, but I'm running into the following issue:

 0:08.14 lld-link: error: undefined symbol: protected: __cdecl mozilla::PrintfTarget::PrintfTarget(void)
 0:08.14 >>> referenced by c:\dev\firefox-unified\obj-x86_64-pc-mingw32\dist\include\mozilla\Sprintf.h:84
 0:08.14 >>>               Assertions.obj:(int __cdecl VsprintfLiteral<1024>(char (&)[1024], char const *, char *))
 0:08.14 lld-link: error: undefined symbol: public: bool __cdecl mozilla::PrintfTarget::vprint(char const *, char *)
 0:08.14 >>> referenced by c:\dev\firefox-unified\obj-x86_64-pc-mingw32\dist\include\mozilla\Sprintf.h:84
 0:08.14 >>>               Assertions.obj:(int __cdecl VsprintfLiteral<1024>(char (&)[1024], char const *, char *))

I'll dig in, but pointers are welcome - I'm not familiar with the domain here.

We need to add some of mozglue/misc for the memory project. I've worked around this somewhere or other but can't find it right now :(

"memory" and "tools/update-programs" do not require
the VisualStudio backend.

Replay, moajemalloc_info, phc, and ???

Depends on D114651

Pushed by mhentges@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a0825e5abc61 Add tools to VisualStudio backend exclusions r=firefox-build-system-reviewers,nalexander https://hg.mozilla.org/integration/autoland/rev/21e6408f323a Adds required sources for the "memory" application r=firefox-build-system-reviewers,glandium
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: