Skip to content

Commit

Permalink
Statically link glib libraries (#730)
Browse files Browse the repository at this point in the history
* Bump timeout to 59 seconds

* Bump version to 2.6.2

* Update indexer build to include static library flags.

* Fixed reference  to OS_TYPE environment variable.

* Added additional GOTAGLIST and GOBUILDMODE flags.

* Added static ld flags to release.py script.

* Updated makefile static ld flags.

* Revert formatting change.

Co-authored-by: Brice Rising <[email protected]>
Co-authored-by: Barbara Poon <[email protected]>
  • Loading branch information
3 people authored Oct 12, 2021
1 parent 25058e5 commit 315edac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@ OS_TYPE ?= $(shell $(SRCPATH)/mule/scripts/ostype.sh)
ARCH ?= $(shell $(SRCPATH)/mule/scripts/archtype.sh)
PKG_DIR = $(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(VERSION)

ifeq ($(OS_TYPE), linux)
EXTLDFLAGS := -static-libstdc++ -static-libgcc
ifeq ($(ARCH), amd64)
ifeq (,$(wildcard /etc/centos-release))
EXTLDFLAGS += -static
endif
endif
ifeq ($(ARCH), arm)
ifneq ("$(wildcard /etc/alpine-release)","")
EXTLDFLAGS += -static
endif
endif
endif
ifneq (, $(findstring MINGW,$(OS_TYPE)))
EXTLDFLAGS := -static -static-libstdc++ -static-libgcc
endif


# TODO: ensure any additions here are mirrored in misc/release.py
GOLDFLAGS += -X github.com/algorand/indexer/version.Hash=$(shell git log -n 1 --pretty="%H")
GOLDFLAGS += -X github.com/algorand/indexer/version.Dirty=$(if $(filter $(strip $(shell git status --porcelain|wc -c)), "0"),,true)
GOLDFLAGS += -X github.com/algorand/indexer/version.CompileTime=$(shell date -u +%Y-%m-%dT%H:%M:%S%z)
GOLDFLAGS += -X github.com/algorand/indexer/version.GitDecorateBase64=$(shell git log -n 1 --pretty="%D"|base64|tr -d ' \n')
GOLDFLAGS += -X github.com/algorand/indexer/version.ReleaseVersion=$(shell cat .version)
GOLDFLAGS += -extldflags \"$(EXTLDFLAGS)\"

# Used for e2e test
export GO_IMAGE = golang:$(shell go version | cut -d ' ' -f 3 | tail -c +3 )
Expand Down
6 changes: 4 additions & 2 deletions misc/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def link(sourcepath, destpath):

_tagpat = re.compile(r'tag:\s+([^,\n]+)')

def compile_version_opts(release_version=None, allow_mismatch=False):
def compile_version_opts(hostos, release_version=None, allow_mismatch=False):
result = subprocess.run(['git', 'log', '-n', '1', '--pretty=%H %D'], stdout=subprocess.PIPE)
result.check_returncode()
so = result.stdout.decode()
Expand Down Expand Up @@ -132,6 +132,8 @@ def compile_version_opts(release_version=None, allow_mismatch=False):
ldflags += ' -X github.com/algorand/indexer/version.GitDecorateBase64={}'.format(base64.b64encode(desc.encode()).decode())
if release_version:
ldflags += ' -X github.com/algorand/indexer/version.ReleaseVersion={}'.format(release_version)
if hostos == 'linux':
ldflags += ' -extldflags "-static -static-libstdc++ -static-libgcc"'
logger.debug('Hash=%r Dirty=%r CompileTime=%r decorate=%r ReleaseVersion=%r', githash, dirty, now, desc, release_version)
logger.debug('%s', ldflags)
return ldflags
Expand Down Expand Up @@ -245,7 +247,7 @@ def main():
logger.info('will only run %s %s', hostos, hostarch)
with open('.version') as fin:
version = fin.read().strip()
ldflags = compile_version_opts(version, allow_mismatch=args.fake_release)
ldflags = compile_version_opts(hostos, version, allow_mismatch=args.fake_release)
for goos, goarch, debarch in osArchArch:
if args.host_only and (goos != hostos or goarch != hostarch):
logger.debug('skip %s %s', goos, goarch)
Expand Down

0 comments on commit 315edac

Please sign in to comment.