Skip to content

Commit 1ccdc8c

Browse files
committed
prevent re-export of symbols from harfbuzz, libpng and zlib
1 parent 0c1219d commit 1ccdc8c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

setup-build-freetype.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
'-DCMAKE_PREFIX_PATH="{}" '
6262
'-DCMAKE_INSTALL_PREFIX="{}" '
6363
).format(prefix_dir, prefix_dir)
64+
CMAKE_PREVENT_REEXPORT = ""
6465

6566
# Try to use Ninja to build things if it's available. Much faster.
6667
# On Windows, I first need to figure out how to make it aware of VC, bitness,
@@ -81,6 +82,12 @@
8182
print("# Making a 32 bit build.")
8283
bitness = 32
8384

85+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libharfbuzz "
86+
if BUILD_ZLIB or BUILD_LIBPNG:
87+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libz "
88+
if BUILD_LIBPNG:
89+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libpng "
90+
8491
if sys.platform == "darwin":
8592
print("# Making a 64 bit build.")
8693
CMAKE_GLOBAL_SWITCHES += (
@@ -91,6 +98,14 @@
9198
)
9299
bitness = 64
93100

101+
# the library path is needed for the '-hidden-lx' option to work
102+
CMAKE_PREVENT_REEXPORT += "-Wl,-L{} ".format(lib_dir)
103+
CMAKE_PREVENT_REEXPORT += "-Wl,-hidden-lharfbuzz "
104+
if BUILD_ZLIB or BUILD_LIBPNG:
105+
CMAKE_PREVENT_REEXPORT += "-Wl,-hidden-lz "
106+
if BUILD_LIBPNG:
107+
CMAKE_PREVENT_REEXPORT += "-Wl,-hidden-lpng "
108+
94109
if "linux" in sys.platform:
95110
c_flags = cxx_flags = "-O2"
96111
ld_flags = ""
@@ -124,6 +139,12 @@
124139
'-DCMAKE_LD_FLAGS="{}" '.format(ld_flags)
125140
)
126141

142+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libharfbuzz "
143+
if BUILD_ZLIB or BUILD_LIBPNG:
144+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libz "
145+
if BUILD_LIBPNG:
146+
CMAKE_PREVENT_REEXPORT += "-Wl,--exclude-libs,libpng "
147+
127148

128149
def shell(cmd, cwd=None):
129150
"""Run a shell command specified by cmd string."""
@@ -249,8 +270,10 @@ def ensure_downloaded(url, sha256_sum):
249270
'-DHarfBuzz_INCLUDE_DIRS="{}" '
250271
'-DPNG_INCLUDE_DIRS="{}" '
251272
'-DZLIB_INCLUDE_DIRS="{}" '
273+
# prevent re-export of symbols from harfbuzz, libpng and zlib
274+
'-DCMAKE_SHARED_LINKER_FLAGS="{}" '
252275
"-DSKIP_INSTALL_HEADERS=ON "
253-
"{} ..".format(harfbuzz_includes, libpng_includes, zlib_includes, CMAKE_GLOBAL_SWITCHES),
276+
"{} ..".format(harfbuzz_includes, libpng_includes, zlib_includes, CMAKE_PREVENT_REEXPORT, CMAKE_GLOBAL_SWITCHES),
254277
cwd=build_dir_ft,
255278
)
256279
shell("cmake --build . --config Release --target install --parallel", cwd=build_dir_ft)

0 commit comments

Comments
 (0)