Skip to content

Commit

Permalink
Merge pull request #1861 from gridcoin-community/revert-1859-musl
Browse files Browse the repository at this point in the history
Revert "build: Add support for building with musl and Alpine Linux"
  • Loading branch information
jamescowens authored Sep 2, 2020
2 parents 0d1b10a + 224267f commit 1d7c353
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 124 deletions.
9 changes: 1 addition & 8 deletions depends/config.guess
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,7 @@ Linux|GNU|GNU/*)
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`

# If ldd exists, use it to detect musl libc.
if command -v ldd >/dev/null && \
ldd --version 2>&1 | grep -q ^musl
then
LIBC=musl
fi
;;
;;
esac

# Note: order is significant - the case branches are not exclusive.
Expand Down
22 changes: 9 additions & 13 deletions depends/packages/fontconfig.mk
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
package=fontconfig
GCCFLAGS?=
$(package)_version=2.12.1
$(package)_download_path=https://www.freedesktop.org/software/fontconfig/release/
$(package)_download_path=http://www.freedesktop.org/software/fontconfig/release/
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3
$(package)_dependencies=freetype expat
$(package)_patches=0001-Avoid-conflicts-with-integer-width-macros-from-TS-18.patch

define $(package)_set_vars
$(package)_config_opts=--disable-docs --disable-static --disable-libxml2 --disable-iconv
$(package)_config_opts += --disable-dependency-tracking --enable-option-checking
$(package)_config_opts=--disable-docs --disable-static
$(package)_cxxflags_aarch64_linux = $(GCCFLAGS)
$(package)_cflags_aarch64_linux = $(GCCFLAGS)
$(package)_cxxflags_arm_linux = $(GCCFLAGS)
$(package)_cflags_arm_linux = $(GCCFLAGS)
endef

define $(package)_config_cmds
patch -p1 < $($(package)_patch_dir)/0001-Avoid-conflicts-with-integer-width-macros-from-TS-18.patch &&\
$($(package)_autoconf)
endef

# 2.12.1 uses CHAR_WIDTH which is reserved and clashes with some glibc versions, but newer versions of fontconfig
# have broken makefiles which needlessly attempt to re-generate headers with gperf.
# Instead, change all uses of CHAR_WIDTH, and disable the rule that forces header re-generation.
# This can be removed once the upstream build is fixed.
define $(package)_build_cmds
sed -i 's/CHAR_WIDTH/CHARWIDTH/g' fontconfig/fontconfig.h src/fcobjshash.gperf src/fcobjs.h src/fcobjshash.h && \
sed -i 's/fcobjshash.h: fcobjshash.gperf/fcobjshash.h:/' src/Makefile && \
$(MAKE)
endef

define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install
endef

define $(package)_postprocess_cmds
rm lib/*.la
endef
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 20cddc824c6501c2082cac41b162c34cd5fcc530 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 11 Dec 2016 14:32:00 -0800
Subject: [PATCH] Avoid conflicts with integer width macros from TS
18661-1:2014

glibc 2.25+ has now defined these macros in <limits.h>
https://sourceware.org/git/?p=glibc.git;a=commit;h=5b17fd0da62bf923cb61d1bb7b08cf2e1f1f9c1a

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Submitted

fontconfig/fontconfig.h | 2 +-
src/fcobjs.h | 2 +-
src/fcobjshash.gperf | 2 +-
src/fcobjshash.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)

Index: fontconfig-2.12.1/fontconfig/fontconfig.h
===================================================================
--- fontconfig-2.12.1.orig/fontconfig/fontconfig.h
+++ fontconfig-2.12.1/fontconfig/fontconfig.h
@@ -128,7 +128,8 @@ typedef int FcBool;
#define FC_USER_CACHE_FILE ".fonts.cache-" FC_CACHE_VERSION

/* Adjust outline rasterizer */
-#define FC_CHAR_WIDTH "charwidth" /* Int */
+#define FC_CHARWIDTH "charwidth" /* Int */
+#define FC_CHAR_WIDTH FC_CHARWIDTH
#define FC_CHAR_HEIGHT "charheight"/* Int */
#define FC_MATRIX "matrix" /* FcMatrix */

Index: fontconfig-2.12.1/src/fcobjs.h
===================================================================
--- fontconfig-2.12.1.orig/src/fcobjs.h
+++ fontconfig-2.12.1/src/fcobjs.h
@@ -51,7 +51,7 @@ FC_OBJECT (DPI, FcTypeDouble, NULL)
FC_OBJECT (RGBA, FcTypeInteger, NULL)
FC_OBJECT (SCALE, FcTypeDouble, NULL)
FC_OBJECT (MINSPACE, FcTypeBool, NULL)
-FC_OBJECT (CHAR_WIDTH, FcTypeInteger, NULL)
+FC_OBJECT (CHARWIDTH, FcTypeInteger, NULL)
FC_OBJECT (CHAR_HEIGHT, FcTypeInteger, NULL)
FC_OBJECT (MATRIX, FcTypeMatrix, NULL)
FC_OBJECT (CHARSET, FcTypeCharSet, FcCompareCharSet)
Index: fontconfig-2.12.1/src/fcobjshash.gperf
===================================================================
--- fontconfig-2.12.1.orig/src/fcobjshash.gperf
+++ fontconfig-2.12.1/src/fcobjshash.gperf
@@ -44,7 +44,7 @@ int id;
"rgba",FC_RGBA_OBJECT
"scale",FC_SCALE_OBJECT
"minspace",FC_MINSPACE_OBJECT
-"charwidth",FC_CHAR_WIDTH_OBJECT
+"charwidth",FC_CHARWIDTH_OBJECT
"charheight",FC_CHAR_HEIGHT_OBJECT
"matrix",FC_MATRIX_OBJECT
"charset",FC_CHARSET_OBJECT
Index: fontconfig-2.12.1/src/fcobjshash.h
===================================================================
--- fontconfig-2.12.1.orig/src/fcobjshash.h
+++ fontconfig-2.12.1/src/fcobjshash.h
@@ -284,7 +284,7 @@ FcObjectTypeLookup (register const char
{(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str43,FC_CHARSET_OBJECT},
{-1},
#line 47 "fcobjshash.gperf"
- {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHAR_WIDTH_OBJECT},
+ {(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str45,FC_CHARWIDTH_OBJECT},
#line 48 "fcobjshash.gperf"
{(int)(long)&((struct FcObjectTypeNamePool_t *)0)->FcObjectTypeNamePool_str46,FC_CHAR_HEIGHT_OBJECT},
#line 55 "fcobjshash.gperf"

6 changes: 5 additions & 1 deletion doc/assets-attribution.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Assets Attribution
===================

Code: src/strlcpy.h
Author: Todd C. Miller <Todd.Miller@courtesan.com>
License: ISC

Icon: src/qt/res/icons/clock*.png,
src/qt/res/src/*.svg
Designer: Wladimir van der Laan
Expand Down Expand Up @@ -32,7 +36,7 @@ License: LGPL
Icon: scripts/img/reload.xcf (modified),src/qt/res/movies/update_spinner.mng
Icon Pack: Kids
Designer: Everaldo (Everaldo Coelho)
License: GNU/GPL
License: GNU/GPL
Site: http://findicons.com/icon/17102/reload?id=17102

Gridcoin Logo: CryptoCoinTalk Community
25 changes: 1 addition & 24 deletions doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Dependency Build Instructions: Ubuntu & Debian
----------------------------------------------
Build requirements:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils

Options when installing required Boost library files:

Expand Down Expand Up @@ -198,29 +198,6 @@ Once these are installed, they will be found by configure and a gridcoinresearch
built by default.


Dependency Build Instructions: Alpine Linux
----------------------------------------------

Build requirements:

apk add autoconf automake boost-dev build-base curl-dev db-dev libtool libzip-dev miniupnpc-dev openssl-dev pkgconfig

**Note:** Alpine Linux only includes Berkeley DB version 5.3 in the package repositories, so we must
run _configure_ with the following option:

./configure --with-incompatible-bdb

To build the wallet with Berkeley DB version 4.8, we need to compile the library from source. See the
[README](../depends/README.md) in the depends directory for one option.

Dependencies for the GUI: Alpine Linux
-----------------------------------------

To build the Qt GUI on Alpine Linux, we need these dependencies:

apk add libqrencode-dev protobuf-dev qt5-qtbase-dev qt5-qtcharts-dev qt5-qtsvg-dev qt5-qttools-dev


Setup and Build Example: Arch Linux
-----------------------------------
This example lists the steps necessary to setup and build a command line only of the latest changes on Arch Linux:
Expand Down
1 change: 1 addition & 0 deletions gridcoinresearch.pro
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ HEADERS += src/qt/bitcoingui.h \
src/scrypt.h \
src/pbkdf2.h \
src/serialize.h \
src/strlcpy.h \
src/main.h \
src/miner.h \
src/net.h \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ GRIDCOIN_CORE_H = \
serialize.h \
span.h \
streams.h \
strlcpy.h \
support/allocators/secure.h \
support/allocators/zeroafterfree.h \
support/cleanse.h \
Expand Down
2 changes: 1 addition & 1 deletion src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/fcntl.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
Expand Down
18 changes: 10 additions & 8 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#endif

#ifndef WIN32
#include <fcntl.h>
#include <sys/fcntl.h>
#endif

#include "strlcpy.h"
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()

using namespace std;

Expand Down Expand Up @@ -91,16 +91,18 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign

bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
std::string str(pszName);
std::string strHost = str;
if (str.empty())
if (pszName[0] == 0)
return false;
if (boost::algorithm::starts_with(str, "[") && boost::algorithm::ends_with(str, "]"))
char psz[256];
char *pszHost = psz;
strlcpy(psz, pszName, sizeof(psz));
if (psz[0] == '[' && psz[strlen(psz)-1] == ']')
{
strHost = str.substr(1, str.size() - 2);
pszHost = psz+1;
psz[strlen(psz)-1] = 0;
}

return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup);
return LookupIntern(pszHost, vIP, nMaxSolutions, fAllowLookup);
}

bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
Expand Down
90 changes: 90 additions & 0 deletions src/strlcpy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef BITCOIN_STRLCPY_H
#define BITCOIN_STRLCPY_H

#include <stdlib.h>
#include <string.h>

/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
inline size_t strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;

/* Copy as many bytes as will fit */
if (n != 0)
{
while (--n != 0)
{
if ((*d++ = *s++) == '\0')
break;
}
}

/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0)
{
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}

return(s - src - 1); /* count does not include NUL */
}

/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
inline size_t strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
size_t dlen;

/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;

if (n == 0)
return(dlen + strlen(s));
while (*s != '\0')
{
if (n != 1)
{
*d++ = *s;
n--;
}
s++;
}
*d = '\0';

return(dlen + (s - src)); /* count does not include NUL */
}
#endif
Loading

0 comments on commit 1d7c353

Please sign in to comment.