1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

Remove symbols from version script

The version script didn't account for symbols disabled by configuration
options. This has caused problems on some OSs in the past and breaks
lld 16 which enables --no-undefined-version by default.

A proper fix would be rather involved, so we simply remove all symbols
from the version script. This is an ELF-only feature and libxml2 never
made use of symbol versioning anyway. Ultimately, this removes the need
for a lot of bookkeeping without tangible benefits.

We have to keep the version nodes to avoid errors when running binaries
linked against older versions of libxml2.

Fixes #473.
This commit is contained in:
Nick Wellnhofer 2023-01-17 16:08:06 +01:00
parent e6401b68df
commit bbb2b8f136
5 changed files with 48 additions and 4223 deletions

View File

@ -58,10 +58,7 @@ dist_man_MANS = xml2-config.1 xmllint.1 xmlcatalog.1
EXTRA_DIST = \
apibuild.py \
checkapisym.xsl \
libxml2-api.xml \
symbols.xml \
syms.xsl \
xmlcatalog.xml \
xmllint.xml
@ -69,8 +66,6 @@ DOCBOOK_HTML = http://docbook.sourceforge.net/release/xsl/current/html/docbook.x
rebuild:
cd $(srcdir) && ./apibuild.py
cd $(srcdir) && $(XSLTPROC) checkapisym.xsl libxml2-api.xml
cd $(srcdir) && $(XSLTPROC) -o ../libxml2.syms syms.xsl symbols.xml
cd $(srcdir) && $(XSLTPROC) -o ../win32/libxml2.def.src ../win32/defgen.xsl libxml2-api.xml
cd $(srcdir) && $(XSLTPROC) --nonet xmllint.xml
cd $(srcdir) && $(XSLTPROC) --nonet -o xmllint.html $(DOCBOOK_HTML) xmllint.xml

View File

@ -1,48 +0,0 @@
<?xml version="1.0"?>
<!-- This stylesheet is used to check that symbols exported
from libxml2-api.xml are also present in the symbol file
symbols.xml which is used to generate libxml2.syms setting
up the allowed access point to the shared libraries -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="syms" select="document('symbols.xml')"/>
<xsl:template match="/">
<xsl:message terminate="no">
<xsl:text>Looking for functions in symbols.xml</xsl:text>
</xsl:message>
<xsl:apply-templates select="/api/symbols/function"/>
<xsl:message terminate="no">
<xsl:text>Found </xsl:text>
<xsl:value-of select="count(/api/symbols/function)"/>
<xsl:text> functions</xsl:text>
</xsl:message>
<xsl:message terminate="no">
<xsl:text>Looking for variables in symbols.xml</xsl:text>
</xsl:message>
<xsl:apply-templates select="/api/symbols/variable"/>
<xsl:message terminate="no">
<xsl:text>Found </xsl:text>
<xsl:value-of select="count(/api/symbols/variable)"/>
<xsl:text> variables</xsl:text>
</xsl:message>
</xsl:template>
<xsl:template match="function|variable">
<xsl:variable name="name" select="@name"/>
<xsl:variable name="symbol"
select="$syms/symbols/release/symbol[. = $name]"/>
<xsl:if test="string($symbol) != $name">
<xsl:message terminate="yes">
<xsl:text>Failed to find export in symbols.xml: </xsl:text>
<xsl:value-of select="$name"/>
</xsl:message>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load Diff

View File

@ -1,99 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="api" select="document('libxml2-api.xml')"/>
<xsl:template match="/">
<xsl:text>#
# Officially exported symbols, for which header
# file definitions are installed in /usr/include/libxml2
#
# Automatically generated from symbols.xml and syms.xsl
#
# Versions here are *fixed* to match the libxml2 version
# at which the symbol was introduced. This ensures that
# a new client app requiring symbol foo() can't accidentally
# run with old libxml2.so not providing foo() - the global
# soname version info can't enforce this since we never
# change the soname
#
</xsl:text>
<xsl:apply-templates select="/symbols/release"/>
</xsl:template>
<xsl:template match="release">
<xsl:variable name="prev"
select="preceding-sibling::release[position()=1]"/>
<xsl:text>LIBXML2_</xsl:text>
<xsl:value-of select="string(@version)"/>
<xsl:text> {
global:
</xsl:text>
<xsl:for-each select="symbol">
<xsl:if test="string(preceding-sibling::symbol[position()=1]/@file) != string(@file)">
<xsl:text>
# </xsl:text>
<xsl:value-of select="@file"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:text>} </xsl:text>
<xsl:if test="$prev">
<xsl:text>LIBXML2_</xsl:text>
<xsl:value-of select="$prev/@version"/>
</xsl:if>
<xsl:text>;
</xsl:text>
</xsl:template>
<xsl:template match="symbol">
<xsl:variable name="name" select="string(.)"/>
<xsl:variable name="file" select="string(@file)"/>
<xsl:choose>
<xsl:when test="@removed">
<xsl:text># </xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>; removed in </xsl:text>
<xsl:value-of select="@removed"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- make sure we can find that symbol exported from the API list -->
<xsl:variable name="def"
select="$api/api/files/file[@name = $file]/exports[@symbol = $name]"/>
<xsl:if test="string($def/@symbol) != $name">
<xsl:message terminate="yes">
<xsl:text>Failed to find definition in libxml2-api.xml:</xsl:text>
<xsl:value-of select="$name"/>
</xsl:message>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>;</xsl:text>
<xsl:if test="$def/@type = 'variable'">
<xsl:text> # variable</xsl:text>
</xsl:if>
<xsl:if test="@comment">
<xsl:text># </xsl:text>
<xsl:value-of select="@comment"/>
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load Diff