未验证 提交 844f48ea 编写于 作者: E Ebrahim Byagowi 提交者: GitHub

Fix symbol exporting and libstdc++ linkage of hb-subset (#769)

上级 91519c6a
...@@ -544,17 +544,15 @@ if (UNIX OR MINGW) ...@@ -544,17 +544,15 @@ if (UNIX OR MINGW)
# Make symbols link locally # Make symbols link locally
link_libraries(-Bsymbolic-functions) link_libraries(-Bsymbolic-functions)
# Make sure we don't link to libstdc++
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Make sure we don't link to libstdc++
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm
set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "") set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C) set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C)
set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C) set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
endif ()
# No threadsafe statics as we do it ourselves # No threadsafe statics as we do it ourselves
if (BUILD_SHARED_LIBS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
endif () endif ()
endif () endif ()
......
...@@ -136,6 +136,7 @@ pkgconfig_DATA = harfbuzz.pc ...@@ -136,6 +136,7 @@ pkgconfig_DATA = harfbuzz.pc
EXTRA_DIST += harfbuzz.pc.in EXTRA_DIST += harfbuzz.pc.in
lib_LTLIBRARIES += libharfbuzz-subset.la lib_LTLIBRARIES += libharfbuzz-subset.la
libharfbuzz_subset_la_LINK = $(libharfbuzz_la_LINK)
libharfbuzz_subset_la_SOURCES = $(HB_SUBSET_sources) libharfbuzz_subset_la_SOURCES = $(HB_SUBSET_sources)
libharfbuzz_subset_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) libharfbuzz_subset_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS)
libharfbuzz_subset_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS) libharfbuzz_subset_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS)
...@@ -172,6 +173,7 @@ HBSOURCES += $(HB_ICU_sources) ...@@ -172,6 +173,7 @@ HBSOURCES += $(HB_ICU_sources)
HBHEADERS += $(HB_ICU_headers) HBHEADERS += $(HB_ICU_headers)
else else
lib_LTLIBRARIES += libharfbuzz-icu.la lib_LTLIBRARIES += libharfbuzz-icu.la
libharfbuzz_icu_la_LINK = $(libharfbuzz_la_LINK)
libharfbuzz_icu_la_SOURCES = $(HB_ICU_sources) libharfbuzz_icu_la_SOURCES = $(HB_ICU_sources)
libharfbuzz_icu_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(ICU_CFLAGS) libharfbuzz_icu_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(ICU_CFLAGS)
libharfbuzz_icu_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS) libharfbuzz_icu_la_LDFLAGS = $(libharfbuzz_la_LDFLAGS)
...@@ -184,6 +186,7 @@ EXTRA_DIST += harfbuzz-icu.pc.in ...@@ -184,6 +186,7 @@ EXTRA_DIST += harfbuzz-icu.pc.in
if HAVE_GOBJECT if HAVE_GOBJECT
lib_LTLIBRARIES += libharfbuzz-gobject.la lib_LTLIBRARIES += libharfbuzz-gobject.la
libharfbuzz_gobject_la_LINK = $(libharfbuzz_la_LINK)
libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_sources) libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_sources)
nodist_libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_ENUM_sources) nodist_libharfbuzz_gobject_la_SOURCES = $(HB_GOBJECT_ENUM_sources)
libharfbuzz_gobject_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(GOBJECT_CFLAGS) libharfbuzz_gobject_la_CPPFLAGS = $(libharfbuzz_la_CPPFLAGS) $(GOBJECT_CFLAGS)
......
...@@ -27,7 +27,7 @@ for def in $defs; do ...@@ -27,7 +27,7 @@ for def in $defs; do
so=$libs/lib${lib}.$suffix so=$libs/lib${lib}.$suffix
if ! test -f "$so"; then continue; fi if ! test -f "$so"; then continue; fi
# On mac, C symbols are prefixed with _ # On macOS, C symbols are prefixed with _
if test $suffix = dylib; then prefix="_"; fi if test $suffix = dylib; then prefix="_"; fi
EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v " $prefix"'\(_fini\>\|_init\>\|_fdata\>\|_ftext\>\|_fbss\>\|__bss_start\>\|__bss_start__\>\|__bss_end__\>\|_edata\>\|_end\>\|_bss_end__\>\|__end__\>\|__gcov_flush\>\|llvm_\)' | cut -d' ' -f3`" EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v " $prefix"'\(_fini\>\|_init\>\|_fdata\>\|_ftext\>\|_fbss\>\|__bss_start\>\|__bss_start__\>\|__bss_end__\>\|_edata\>\|_end\>\|_bss_end__\>\|__end__\>\|__gcov_flush\>\|llvm_\)' | cut -d' ' -f3`"
......
...@@ -21,16 +21,18 @@ else ...@@ -21,16 +21,18 @@ else
fi fi
tested=false tested=false
for suffix in so dylib; do for soname in harfbuzz harfbuzz-icu harfbuzz-subset; do
so=$libs/libharfbuzz.$suffix for suffix in so dylib; do
if ! test -f "$so"; then continue; fi so=$libs/lib$soname.$suffix
if ! test -f "$so"; then continue; fi
echo "Checking that we are not linking to libstdc++ or libc++" echo "Checking that we are not linking to libstdc++ or libc++"
if $LDD $so | grep 'libstdc[+][+]\|libc[+][+]'; then if $LDD $so | grep 'libstdc[+][+]\|libc[+][+]'; then
echo "Ouch, linked to libstdc++ or libc++" echo "Ouch, linked to libstdc++ or libc++"
stat=1 stat=1
fi fi
tested=true tested=true
done
done done
if ! $tested; then if ! $tested; then
echo "check-libstdc++.sh: libharfbuzz shared library not found; skipping test" echo "check-libstdc++.sh: libharfbuzz shared library not found; skipping test"
......
...@@ -17,24 +17,26 @@ fi ...@@ -17,24 +17,26 @@ fi
echo "Checking that we are not exposing internal symbols" echo "Checking that we are not exposing internal symbols"
tested=false tested=false
for suffix in so dylib; do for soname in harfbuzz harfbuzz-icu harfbuzz-subset; do
so=$libs/libharfbuzz.$suffix for suffix in so dylib; do
if ! test -f "$so"; then continue; fi so=$libs/lib$soname.$suffix
if ! test -f "$so"; then continue; fi
EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| ___gcov_flush\>\| llvm_\| _llvm_' | cut -d' ' -f3`" EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| ___gcov_flush\>\| llvm_\| _llvm_' | cut -d' ' -f3`"
prefix=`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'` prefix=`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'`
# On mac, C symbols are prefixed with _ # On macOS, C symbols are prefixed with _
if test $suffix = dylib; then prefix="_$prefix"; fi if test $suffix = dylib; then prefix="_$prefix"; fi
echo "Processing $so" echo "Processing $so"
if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}_"; then if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}\(_\|$\)"; then
echo "Ouch, internal symbols exposed" echo "Ouch, internal symbols exposed"
stat=1 stat=1
fi fi
tested=true tested=true
done
done done
if ! $tested; then if ! $tested; then
echo "check-symbols.sh: no shared library found; skipping test" echo "check-symbols.sh: no shared library found; skipping test"
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "hb-set.h" #include "hb-set.h"
#include "hb-subset-glyf.hh" #include "hb-subset-glyf.hh"
bool HB_INTERNAL bool
_calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
hb_auto_array_t<unsigned int> &glyph_ids, hb_auto_array_t<unsigned int> &glyph_ids,
bool *use_short_loca, /* OUT */ bool *use_short_loca, /* OUT */
...@@ -63,7 +63,7 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, ...@@ -63,7 +63,7 @@ _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf,
return true; return true;
} }
void HB_INTERNAL void
_write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *loca_prime) { _write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *loca_prime) {
if (is_short) { if (is_short) {
((OT::HBUINT16*) loca_prime) [id].set (offset / 2); ((OT::HBUINT16*) loca_prime) [id].set (offset / 2);
...@@ -72,7 +72,7 @@ _write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *lo ...@@ -72,7 +72,7 @@ _write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *lo
} }
} }
bool HB_INTERNAL bool
_write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf, _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
const char *glyf_data, const char *glyf_data,
hb_auto_array_t<unsigned int> &glyph_ids, hb_auto_array_t<unsigned int> &glyph_ids,
...@@ -110,7 +110,7 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf, ...@@ -110,7 +110,7 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
return true; return true;
} }
bool HB_INTERNAL bool
_hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf, _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf,
const char *glyf_data, const char *glyf_data,
hb_auto_array_t<unsigned int> &glyphs_to_retain, hb_auto_array_t<unsigned int> &glyphs_to_retain,
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"
bool HB_INTERNAL bool
hb_subset_glyf_and_loca (hb_subset_plan_t *plan, hb_subset_glyf_and_loca (hb_subset_plan_t *plan,
hb_face_t *face, hb_face_t *face,
bool *use_short_loca, /* OUT */ bool *use_short_loca, /* OUT */
......
...@@ -49,7 +49,7 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan, ...@@ -49,7 +49,7 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan,
return false; return false;
} }
void HB_INTERNAL void
_populate_codepoints (hb_set_t *input_codepoints, _populate_codepoints (hb_set_t *input_codepoints,
hb_auto_array_t<hb_codepoint_t>& plan_codepoints) hb_auto_array_t<hb_codepoint_t>& plan_codepoints)
{ {
...@@ -62,7 +62,7 @@ _populate_codepoints (hb_set_t *input_codepoints, ...@@ -62,7 +62,7 @@ _populate_codepoints (hb_set_t *input_codepoints,
plan_codepoints.qsort (_hb_codepoint_t_cmp); plan_codepoints.qsort (_hb_codepoint_t_cmp);
} }
void HB_INTERNAL void
_populate_gids_to_retain (hb_face_t *face, _populate_gids_to_retain (hb_face_t *face,
hb_auto_array_t<hb_codepoint_t>& codepoints, hb_auto_array_t<hb_codepoint_t>& codepoints,
hb_auto_array_t<hb_codepoint_t>& old_gids, hb_auto_array_t<hb_codepoint_t>& old_gids,
......
...@@ -45,20 +45,20 @@ struct hb_subset_plan_t { ...@@ -45,20 +45,20 @@ struct hb_subset_plan_t {
typedef struct hb_subset_plan_t hb_subset_plan_t; typedef struct hb_subset_plan_t hb_subset_plan_t;
hb_subset_plan_t * HB_INTERNAL hb_subset_plan_t *
hb_subset_plan_create (hb_face_t *face, hb_subset_plan_create (hb_face_t *face,
hb_subset_profile_t *profile, hb_subset_profile_t *profile,
hb_subset_input_t *input); hb_subset_input_t *input);
hb_bool_t HB_INTERNAL hb_bool_t
hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan, hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
hb_codepoint_t old_gid, hb_codepoint_t old_gid,
hb_codepoint_t *new_gid /* OUT */); hb_codepoint_t *new_gid /* OUT */);
hb_subset_plan_t * HB_INTERNAL hb_subset_plan_t *
hb_subset_plan_get_empty (); hb_subset_plan_get_empty ();
void HB_INTERNAL void
hb_subset_plan_destroy (hb_subset_plan_t *plan); hb_subset_plan_destroy (hb_subset_plan_t *plan);
#endif /* HB_SUBSET_PLAN_HH */ #endif /* HB_SUBSET_PLAN_HH */
...@@ -108,7 +108,7 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input) ...@@ -108,7 +108,7 @@ hb_subset_input_destroy(hb_subset_input_t *subset_input)
} }
template<typename TableType> template<typename TableType>
hb_blob_t * HB_INTERNAL hb_blob_t *
_subset (hb_subset_plan_t *plan, hb_face_t *source) _subset (hb_subset_plan_t *plan, hb_face_t *source)
{ {
OT::Sanitizer<TableType> sanitizer; OT::Sanitizer<TableType> sanitizer;
......
...@@ -4,6 +4,17 @@ noinst_LTLIBRARIES = libhb-ucdn.la ...@@ -4,6 +4,17 @@ noinst_LTLIBRARIES = libhb-ucdn.la
include Makefile.sources include Makefile.sources
if OS_WIN32
libhb_ucdn_la_LINK = $(CXXLINK)
else
# Use a C linker for GCC, not C++; Don't link to libstdc++
if HAVE_GCC
libhb_ucdn_la_LINK = $(LINK)
else
libhb_ucdn_la_LINK = $(CXXLINK)
endif
endif
libhb_ucdn_la_SOURCES = $(LIBHB_UCDN_sources) libhb_ucdn_la_SOURCES = $(LIBHB_UCDN_sources)
libhb_ucdn_la_CPPFLAGS = \ libhb_ucdn_la_CPPFLAGS = \
-I$(top_srcdir) \ -I$(top_srcdir) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册