Skip to content

Commit cf9d046

Browse files
committed
Wrap some GLIBC functions so they point to older versions
1 parent e15ce17 commit cf9d046

File tree

5 files changed

+81
-13
lines changed

5 files changed

+81
-13
lines changed

SConstruct

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ if not env.GetOption('clean'):
111111
if env.get('static') or env.get('mostly_static'):
112112
conf.CBCheckLib('selinux')
113113

114+
if env['PLATFORM'] == 'posix':
115+
funcs = 'exp expf pow powf log logf memcpy'.split()
116+
flags = list(map(lambda n: '-Wl,--wrap=' + n, funcs))
117+
env.AppendUnique(LINKFLAGS = flags)
118+
114119
conf.Finish()
115120

116121

@@ -149,6 +154,7 @@ src = []
149154
subdirs = ['', 'sim', 'probe', 'opt', 'project', 'contour', 'render']
150155
for subdir in subdirs: src += Glob('src/camotics/%s/*.cpp' % subdir)
151156
if env['with_tpl']: src += Glob('src/tplang/*.cpp')
157+
src += ['src/glibc.c']
152158

153159
src = list(map(lambda path: re.sub(r'^src/', 'build/', str(path)), src))
154160

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
## Install packages
1+
## Create and Enter chroot
2+
3+
sudo debootstrap --arch amd64 stable root
4+
sudo chroot root /bin/bash
25

3-
sudo apt-get update
4-
sudo apt-get install -y wget git scons build-essential binutils-dev \
5-
fakeroot python3-pip python3-virtualenv debian-keyring \
6-
debian-archive-keyring ca-certificates libssl-dev
6+
## Install packages
77

8-
## Install systemd service
8+
apt-get update
9+
apt-get install -y wget git scons build-essential binutils-dev fakeroot \
10+
python3-pip debian-keyring debian-archive-keyring ca-certificates git \
11+
libssl-dev buildbot-worker python-six libqt5websockets5-dev \
12+
libqt5opengl5-dev libnode-dev libglu1-mesa-dev pkgconf qttools5-dev-tools
913

10-
Install ``buildbot-worker.service`` on worker, then:
14+
## Install and Start Worker
1115

12-
cd /home/admin/worker
13-
sudo systemctl enable --now $PWD/buildbot-worker.service
16+
mkdir /opt/worker
17+
cd /opt/worker
18+
buildbot-worker create-worker . localhost:8012 debian-stable-64bit \
19+
<password>
20+
buildbot-worker start

buildbot/workers/debian-stable-64bit/build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"props": {"os": "lin"},
33

4+
"env": {
5+
"QT5DIR": "/usr"
6+
},
7+
48
"builds": {
59
"camotics": {"projects": ["camotics"]}
610
}

buildbot/workers/debian-stable-64bit/buildbot-worker.service

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[Unit]
2-
Description=F@H Build Worker
2+
Description=Build Worker
33
After=network.target
44

55
[Service]
66
User=admin
7-
WorkingDirectory=/home/admin/worker
8-
Environment=PATH=/home/admin/worker/bin:/usr/local/bin:/usr/bin:/bin
9-
ExecStart=python3 bin/buildbot-worker start --nodaemon %I
7+
WorkingDirectory=/opt/worker
8+
ExecStart=buildbot-worker start --nodaemon %I
109
Restart=always
1110
RestartSec=4
1211

src/glibc.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/******************************************************************************\
2+
3+
CAMotics is an Open-Source simulation and CAM software.
4+
Copyright (C) 2011-2022 Joseph Coffland <[email protected]>
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 2 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
\******************************************************************************/
20+
21+
#if defined(__GNUC__) && !defined(__clang__) && !defined(_WIN32)
22+
23+
#include <string.h>
24+
#include <math.h>
25+
26+
#if defined(__aarch64__)
27+
#define GLIBC_SYMVER "2.17"
28+
#else
29+
#define GLIBC_SYMVER "2.2.5"
30+
#endif
31+
32+
__asm__(".symver exp,exp@GLIBC_" GLIBC_SYMVER);
33+
__asm__(".symver expf,expf@GLIBC_" GLIBC_SYMVER);
34+
__asm__(".symver log,log@GLIBC_" GLIBC_SYMVER);
35+
__asm__(".symver logf,logf@GLIBC_" GLIBC_SYMVER);
36+
__asm__(".symver pow,pow@GLIBC_" GLIBC_SYMVER);
37+
__asm__(".symver powf,powf@GLIBC_" GLIBC_SYMVER);
38+
__asm__(".symver memcpy,memcpy@GLIBC_" GLIBC_SYMVER);
39+
40+
float __wrap_logf(float x) {return logf(x);}
41+
double __wrap_log(double x) {return log (x);}
42+
float __wrap_expf(float x) {return expf(x);}
43+
double __wrap_exp(double x) {return exp (x);}
44+
float __wrap_powf(float x, float y) {return powf(x, y);}
45+
double __wrap_pow(double x, double y) {return pow (x, y);}
46+
47+
48+
void *__wrap_memcpy(void *restrict dst, const void *restrict src, size_t n) {
49+
return memcpy(dst, src, n);
50+
}
51+
52+
#endif

0 commit comments

Comments
 (0)