Skip to content

Commit bd65994

Browse files
author
Cevap Master
authored
Merge pull request #26 from cevap/gitian-risc
Add risc support
2 parents 290ac97 + c23dc3f commit bd65994

File tree

4 files changed

+39
-35
lines changed

4 files changed

+39
-35
lines changed

contrib/devtools/symbol-check.py

+31-17
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@
3636
# (glibc) GLIBC_2_11
3737
#
3838
MAX_VERSIONS = {
39-
'GCC': (4,4,0),
40-
'CXXABI': (1,3,3),
41-
'GLIBCXX': (3,4,13),
42-
'GLIBC': (2,11)
39+
'GCC': (4,4,0),
40+
'CXXABI': (1,3,3),
41+
'GLIBCXX': (3,4,13),
42+
'GLIBC': (2,11),
43+
'LIBATOMIC': (1,0)
4344
}
4445
# See here for a description of _IO_stdin_used:
4546
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634261#109
4647

4748
# Ignore symbols that are exported as part of every executable
4849
IGNORE_EXPORTS = {
49-
'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used', 'stdin', 'stdout', 'stderr'
50+
'_edata', '_end', '__end__', '_init', '__bss_start', '__bss_start__', '_bss_end__', '__bss_end__', '_fini', '_IO_stdin_used', 'stdin', 'stdout', 'stderr'
5051
}
5152
READELF_CMD = os.getenv('READELF', '/usr/bin/readelf')
5253
CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt')
@@ -59,8 +60,12 @@
5960
'libanl.so.1', # DNS resolve
6061
'libm.so.6', # math library
6162
'librt.so.1', # real-time (clock)
63+
'libatomic.so.1',
6264
'ld-linux-x86-64.so.2', # 64-bit dynamic linker
6365
'ld-linux.so.2', # 32-bit dynamic linker
66+
'ld-linux-aarch64.so.1', # 64-bit ARM dynamic linker
67+
'ld-linux-armhf.so.3', # 32-bit ARM dynamic linker
68+
'ld-linux-riscv64-lp64d.so.1', # 64-bit RISC-V dynamic linker
6469
# bitcoin-qt only
6570
'libX11-xcb.so.1', # part of X11
6671
'libX11.so.6', # part of X11
@@ -69,7 +74,13 @@
6974
'libfreetype.so.6', # font parsing
7075
'libdl.so.2' # programming interface to dynamic linker
7176
}
72-
77+
ARCH_MIN_GLIBC_VER = {
78+
'80386': (2,1),
79+
'X86-64': (2,2,5),
80+
'ARM': (2,4),
81+
'AArch64':(2,17),
82+
'RISC-V': (2,27)
83+
}
7384
class CPPFilt(object):
7485
'''
7586
Demangle C++ symbol names.
@@ -94,23 +105,25 @@ def read_symbols(executable, imports=True):
94105
Parse an ELF executable and return a list of (symbol,version) tuples
95106
for dynamic, imported symbols.
96107
'''
97-
p = subprocess.Popen([READELF_CMD, '--dyn-syms', '-W', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
108+
p = subprocess.Popen([READELF_CMD, '--dyn-syms', '-W', '-h', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
98109
(stdout, stderr) = p.communicate()
99110
if p.returncode:
100111
raise IOError('Could not read symbols for %s: %s' % (executable, stderr.strip()))
101112
syms = []
102113
for line in stdout.splitlines():
103114
line = line.split()
115+
if 'Machine:' in line:
116+
arch = line[-1]
104117
if len(line)>7 and re.match('[0-9]+:$', line[0]):
105118
(sym, _, version) = line[7].partition('@')
106119
is_import = line[6] == 'UND'
107120
if version.startswith('@'):
108121
version = version[1:]
109122
if is_import == imports:
110-
syms.append((sym, version))
123+
syms.append((sym, version, arch))
111124
return syms
112125

113-
def check_version(max_versions, version):
126+
def check_version(max_versions, version, arch):
114127
if '_' in version:
115128
(lib, _, ver) = version.rpartition('_')
116129
else:
@@ -119,7 +132,7 @@ def check_version(max_versions, version):
119132
ver = tuple([int(x) for x in ver.split('.')])
120133
if not lib in max_versions:
121134
return False
122-
return ver <= max_versions[lib]
135+
return ver <= max_versions[lib] or lib == 'GLIBC' and ver <= ARCH_MIN_GLIBC_VER[arch]
123136

124137
def read_libraries(filename):
125138
p = subprocess.Popen([READELF_CMD, '-d', '-W', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
@@ -142,16 +155,17 @@ def read_libraries(filename):
142155
retval = 0
143156
for filename in sys.argv[1:]:
144157
# Check imported symbols
145-
for sym,version in read_symbols(filename, True):
146-
if version and not check_version(MAX_VERSIONS, version):
158+
for sym,version,arch in read_symbols(filename, True):
159+
if version and not check_version(MAX_VERSIONS, version, arch):
147160
print('%s: symbol %s from unsupported version %s' % (filename, cppfilt(sym), version))
148161
retval = 1
149162
# Check exported symbols
150-
for sym,version in read_symbols(filename, False):
151-
if sym in IGNORE_EXPORTS:
152-
continue
153-
print('%s: export of symbol %s not allowed' % (filename, cppfilt(sym)))
154-
retval = 1
163+
if arch != 'RISC-V':
164+
for sym,version,arch in read_symbols(filename, False):
165+
if sym in IGNORE_EXPORTS:
166+
continue
167+
print('%s: export of symbol %s not allowed' % (filename, cppfilt(sym)))
168+
retval = 1
155169
# Check dependency libraries
156170
for library_name in read_libraries(filename):
157171
if library_name not in ALLOWED_LIBRARIES:

contrib/gitian-descriptors/gitian-linux.yml

+2-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ files: []
3838
script: |
3939
4040
WRAP_DIR=$HOME/wrapped
41-
HOSTS="i686-pc-linux-gnu x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu"
41+
HOSTS="i686-pc-linux-gnu x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu"
4242
CONFIGFLAGS="--enable-glibc-back-compat --enable-reduce-exports --disable-bench --disable-gui-tests"
4343
FAKETIME_HOST_PROGS="gcc g++"
4444
FAKETIME_PROGS="date ar ranlib nm"
@@ -172,20 +172,8 @@ script: |
172172
173173
CONFIG_SITE=${BASEPREFIX}/${i}/share/config.site ./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}"
174174
make ${MAKEOPTS}
175-
176175
make ${MAKEOPTS} -C src check-security
177-
178-
#TODO: This is a quick hack that disables symbol checking for arm.
179-
# Instead, we should investigate why these are popping up.
180-
# For aarch64, we'll need to bump up the min GLIBC version, as the abi
181-
# support wasn't introduced until 2.17.
182-
case $i in
183-
aarch64-*) : ;;
184-
arm-*) : ;;
185-
riscv64-*) : ;;
186-
*) make ${MAKEOPTS} -C src check-symbols ;;
187-
esac
188-
176+
make ${MAKEOPTS} -C src check-symbols
189177
make install DESTDIR=${INSTALLPATH}
190178
cd installed
191179
find . -name "lib*.la" -delete

depends/packages/qt.mk

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ $(package)_config_opts_linux += -system-freetype
102102
$(package)_config_opts_linux += -no-feature-sessionmanager
103103
$(package)_config_opts_linux += -fontconfig
104104
$(package)_config_opts_linux += -no-opengl
105-
$(package)_config_opts_arm_linux += -platform linux-g++ -xplatform bitcoin-linux-g++
105+
$(package)_config_opts_arm_linux += -platform linux-g++ -xplatform ion-linux-g++
106106
$(package)_config_opts_i686_linux = -xplatform linux-g++-32
107107
$(package)_config_opts_x86_64_linux = -xplatform linux-g++-64
108108
$(package)_config_opts_aarch64_linux = -xplatform linux-aarch64-gnu-g++
109-
$(package)_config_opts_riscv64_linux = -platform linux-g++ -xplatform bitcoin-linux-g++
109+
$(package)_config_opts_riscv64_linux = -platform linux-g++ -xplatform ion-linux-g++
110110
$(package)_config_opts_mingw32 = -no-opengl -xplatform win32-g++ -device-option CROSS_COMPILE="$(host)-"
111111
$(package)_build_env = QT_RCC_TEST=1
112112
$(package)_build_env += QT_RCC_SOURCE_DATE_OVERRIDE=1
@@ -145,8 +145,8 @@ define $(package)_preprocess_cmds
145145
cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\
146146
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
147147
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
148-
cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/bitcoin-linux-g++ && \
149-
sed -i.old "s/arm-linux-gnueabi-/$(host)-/g" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \
148+
cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/ion-linux-g++ && \
149+
sed -i.old "s/arm-linux-gnueabi-/$(host)-/g" qtbase/mkspecs/ion-linux-g++/qmake.conf && \
150150
patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch &&\
151151
patch -p1 -i $($(package)_patch_dir)/fix_configure_mac.patch &&\
152152
patch -p1 -i $($(package)_patch_dir)/fix_no_printer.patch &&\

src/compat/glibc_compat.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ __asm(".symver log2f_old,log2f@GLIBC_2.2.5");
6969
__asm(".symver log2f_old,log2f@GLIBC_2.4");
7070
#elif defined(__aarch64__)
7171
__asm(".symver log2f_old,log2f@GLIBC_2.17");
72+
#elif defined(__riscv)
73+
__asm(".symver log2f_old,log2f@GLIBC_2.27");
7274
#endif
7375
extern "C" float __wrap_log2f(float x)
7476
{

0 commit comments

Comments
 (0)