Skip to content

Commit

Permalink
Fix missing symbol on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
jushar committed Jun 13, 2017
1 parent f5e095d commit 9da26b5
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 24 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Expand Up @@ -4,6 +4,9 @@ FROM jetbrains/teamcity-agent:latest
# Default value is 0 (manual build)
ENV AS_BUILDAGENT 0

# Set default target platform to 64-bits
ENV BUILD_BITS 64

# Install dependencies to install the latest gcc
RUN apt-get update && \
apt-get install -y software-properties-common wget && \
Expand All @@ -22,5 +25,8 @@ WORKDIR /build
# Copy entrypoint script
COPY utils/docker-entrypoint.sh /docker-entrypoint.sh

# Add GLIB compat
COPY utils/compat /compat

# Set entrypoint
ENTRYPOINT bash /docker-entrypoint.sh
6 changes: 3 additions & 3 deletions premake5.lua
Expand Up @@ -47,13 +47,13 @@ workspace "MTASA"

if GLIBC_COMPAT then
filter { "system:linux" }
includedirs "utils/compat"
includedirs "/compat"
linkoptions "-static-libstdc++ -static-libgcc"
forceincludes { "glibc_version.h" }
filter { "system:linux", "platforms:x86" }
libdirs { "utils/compat/x86" }
libdirs { "/compat/x86" }
filter { "system:linux", "platforms:x64" }
libdirs { "utils/compat/x64" }
libdirs { "/compat/x64" }
end

filter "platforms:x86"
Expand Down
21 changes: 16 additions & 5 deletions utils/compat/glibc_version.h
@@ -1,10 +1,21 @@
// If you change this, remember to also change glibc_version.redef
#pragma once

#ifndef __ASSEMBLER__
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
__asm__(".symver memcmp,memcmp@GLIBC_2.2.5");
#ifdef __x86_64__
#ifndef __ASSEMBLER__
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
__asm__(".symver memcmp,memcmp@GLIBC_2.2.5");
#else
.symver memcpy,memcpy@GLIBC_2.2.5
.symver memcmp,memcmp@GLIBC_2.2.5
#endif
#else
.symver memcpy,memcpy@GLIBC_2.2.5
.symver memcmp,memcmp@GLIBC_2.2.5
#ifndef __ASSEMBLER__
__asm__(".symver memcpy,memcpy@GLIBC_2.0");
__asm__(".symver memcmp,memcmp@GLIBC_2.0");
#else
.symver memcpy,memcpy@GLIBC_2.0
.symver memcmp,memcmp@GLIBC_2.0
#endif

#endif
File renamed without changes.
8 changes: 8 additions & 0 deletions utils/compat/glibc_version_x86.redef
@@ -0,0 +1,8 @@
# Note: use objcopy --redefine-syms=glibc_version.redef sourcepath.a target.a
# to build a static linkable libstdc++ from the system variant using old glibc references
# documented above.
# If you change this, remember to also change glibc_version.h
# See also: create_static_libraries.sh
#
memcmp memcmp@GLIBC_2.0
memcpy memcpy@GLIBC_2.0
32 changes: 16 additions & 16 deletions utils/docker-entrypoint.sh
@@ -1,5 +1,21 @@
#!/bin/bash

# 64-bits
if [ ! -d /compat/x64 ]; then
mkdir -p /compat/x64
objcopy --redefine-syms=/compat/glibc_version_x64.redef /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a /compat/x64/libstdc++.a
objcopy --redefine-syms=/compat/glibc_version_x64.redef /usr/lib/x86_64-linux-gnu/libmysqlclient.a /compat/x64/libmysqlclient.a
fi

# 32-bits
if [ ! -d /compat/x86 ] && [[ $BUILD_BITS = "32" ]]; then
apt-get install -y libmysqlclient-dev:i386
mkdir -p /compat/x86
objcopy --redefine-syms=/compat/glibc_version_x86.redef /usr/lib/gcc/x86_64-linux-gnu/5/32/libstdc++.a /compat/x86/libstdc++.a
objcopy --redefine-syms=/compat/glibc_version_x86.redef /usr/lib/i386-linux-gnu/libmysqlclient.a /compat/x86/libmysqlclient.a
fi


# If configurede as a build agent, start Teamcity agent
if [[ $AS_BUILDAGENT = "1" ]]; then
# https://github.com/JetBrains/teamcity-docker-minimal-agent/blob/master/Dockerfile#L17
Expand All @@ -13,22 +29,6 @@ if [ ! -f ./premake5.lua ]; then
git clone --depth=1 https://github.com/multitheftauto/mtasa-blue.git .
fi

# Build compatibility libraries
# 64-bit
if [ ! -d utils/compat/x64 ]; then
mkdir utils/compat/x64
objcopy --redefine-syms=utils/compat/glibc_version.redef /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a utils/compat/x64/libstdc++.a
objcopy --redefine-syms=utils/compat/glibc_version.redef /usr/lib/x86_64-linux-gnu/libmysqlclient.a utils/compat/x64/libmysqlclient.a
fi

# 32-bit
if [ ! -d utils/compat/x86 ]; then
apt-get install -y libmysqlclient-dev:i386 # Install here as x64 and x86 cannot be installed in parallel
mkdir utils/compat/x86
objcopy --redefine-syms=utils/compat/glibc_version.redef /usr/lib/gcc/x86_64-linux-gnu/5/32/libstdc++.a utils/compat/x86/libstdc++.a
objcopy --redefine-syms=utils/compat/glibc_version.redef /usr/lib/i386-linux-gnu/libmysqlclient.a utils/compat/x86/libmysqlclient.a
fi

# Start manual building
export GLIBC_COMPAT=true
./linux-build.sh $BUILD_BITS

0 comments on commit 9da26b5

Please sign in to comment.