Potential build issue

Discussions about the development and maturation of the platform code (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, athenian200

dbsoft
Project Contributor
Project Contributor
Posts: 467
Joined: 2020-02-21, 17:35

Potential build issue

Unread post by dbsoft » 2024-07-29, 07:54

I installed clang 17 on an old Mac that have at a location I've been spending a lot of time at. It only can run up to MacOS 10.11 El Capitan. The Xcode I am using for builds (which cannot run on this Mac) currently is based on clang 16. I am getting an error in the compiler headers when it tries to call "std::realloc()" using clang 17, I have not tried with other systems using clang 17 yet, or the beta of the new Xcode presumably based on clang 17... but in the MacPorts clang 17 I am having this problem:

Essentially it boils down to Mozilla's redefining relloc() to moz_xrealloc() using #defines. It occurs in gfx/graphite2/src/Collider.cpp when including C++ headers. It should not happen during a normal compile because they are the first things included in the file, but because of unified building something includes code that does the moz_xrealloc redefine.

Because the #define is just changing the function name it tries to call "std::moz_xrealloc()" which does not exist in the std:: namespace.

This is the temporary fix I did to get it to build:

Code: Select all

diff --git a/gfx/graphite2/src/Collider.cpp b/gfx/graphite2/src/Collider.cpp
index 035bb9a..3b57beb 100644
--- a/gfx/graphite2/src/Collider.cpp
+++ b/gfx/graphite2/src/Collider.cpp
@@ -24,6 +24,9 @@ Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
 License, as published by the Free Software Foundation, either version 2
 of the License or (at your option) any later version.
 */
+#ifdef realloc
+#undef realloc
+#endif
 #include <algorithm>
 #include <limits>
 #include <cmath>
However it could also be fixed by removing that file from the unified build.

If this turns out to be a problem with all clang 17 compilers should I remove this file from unified building or try to locate the file(s) defining moz_xrealloc and remove them from the unified build? Or should I just add something ugly like this?

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36453
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Potential build issue

Unread post by Moonchild » 2024-07-29, 08:07

Remove it from the unified build.
Unified building doesn't always work especially if there are header conflicts (either with system headers or between unified files) and the proper solution is to just not build unified, not do hacky things in the sources themselves.
"A programmer is someone who solves a problem you didn't know you had, in a way you don't understand." -- unknown
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

dbsoft
Project Contributor
Project Contributor
Posts: 467
Joined: 2020-02-21, 17:35

Re: Potential build issue

Unread post by dbsoft » 2024-07-29, 08:22

Yeah, that was my inclination, but when dealing with overriding allocator functions removing a single file from it could potentially cause problems.... so thought it best to ask. :)

Post Reply