From e2d66b33facf629b25a9dd7c4cf20db2f846dcf5 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Tue, 12 Oct 2021 14:55:13 -0700 Subject: [PATCH] fix: Fix crash in static-linked linux builds The official, static-linked linux builds were crashing in their use of getaddrinfo, which libcurl was configured to use. Both getaddrinfo and all of its alternatives available in glibc fail with static linking. We can fix this by configuring libcurl to use libc-ares on Linux instead. This allows us to keep the benefits of a statically-linked Linux binary. Closes #996 Change-Id: Ib4a9eb939813fd165727788726459ef4adf3fc4d --- .../workflows/custom-actions/build-packager/action.yaml | 9 +++++++++ docs/source/build_instructions.md | 7 +++++-- packager/testing/dockers/Alpine_Dockerfile | 2 +- packager/testing/dockers/ArchLinux_Dockerfile | 1 + packager/testing/dockers/CentOS_Dockerfile | 2 +- packager/testing/dockers/Debian_Dockerfile | 1 + packager/testing/dockers/Fedora_Dockerfile | 2 +- packager/testing/dockers/OpenSUSE_Dockerfile | 1 + packager/testing/dockers/Ubuntu_Dockerfile | 1 + packager/third_party/curl/curl.gyp | 6 ++++++ 10 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/custom-actions/build-packager/action.yaml b/.github/workflows/custom-actions/build-packager/action.yaml index c875bb7844..f39ca248cd 100644 --- a/.github/workflows/custom-actions/build-packager/action.yaml +++ b/.github/workflows/custom-actions/build-packager/action.yaml @@ -43,6 +43,15 @@ runs: echo "::endgroup::" fi + - name: Install c-ares (Linux only) + shell: bash + run: | + if [[ "${{ runner.os }}" == "Linux" ]]; then + echo "::group::Install c-ares" + sudo apt install -y libc-ares-dev + echo "::endgroup::" + fi + - name: Install depot tools shell: bash run: | diff --git a/docs/source/build_instructions.md b/docs/source/build_instructions.md index 33d99acbab..cca855113a 100644 --- a/docs/source/build_instructions.md +++ b/docs/source/build_instructions.md @@ -12,6 +12,7 @@ for [other distros below](#notes-for-other-linux-distros). sudo apt-get update sudo apt-get install -y \ curl \ + libc-ares-dev \ build-essential git python python3 ``` @@ -243,7 +244,7 @@ Use `apk` command to install dependencies: ```shell apk add --no-cache \ bash curl \ - bsd-compat-headers linux-headers \ + bsd-compat-headers c-ares-dev linux-headers \ build-base git ninja python2 python3 ``` @@ -270,6 +271,7 @@ Instead of running `sudo apt-get install` to install build dependencies, run: ```shell sudo pacman -Sy --needed \ core/which \ + c-ares \ gcc git python2 python3 ``` @@ -284,7 +286,7 @@ Instead of running `sudo apt-get install` to install build dependencies, run: ```shell su -c 'yum install -y \ which \ - libatomic \ + c-ares-devel libatomic \ gcc-c++ git python2' ``` @@ -299,6 +301,7 @@ Use `zypper` command to install dependencies: ```shell sudo zypper in -y \ curl which \ + c-ares-devel \ gcc-c++ git python python3 ``` diff --git a/packager/testing/dockers/Alpine_Dockerfile b/packager/testing/dockers/Alpine_Dockerfile index 0ef955596f..2ce7850a49 100644 --- a/packager/testing/dockers/Alpine_Dockerfile +++ b/packager/testing/dockers/Alpine_Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3.11 # Install utilities, libraries, and dev tools. RUN apk add --no-cache \ bash curl \ - bsd-compat-headers linux-headers \ + bsd-compat-headers c-ares-dev linux-headers \ build-base git ninja python2 python3 # Install depot_tools. diff --git a/packager/testing/dockers/ArchLinux_Dockerfile b/packager/testing/dockers/ArchLinux_Dockerfile index a461161fb3..e5065e9b73 100644 --- a/packager/testing/dockers/ArchLinux_Dockerfile +++ b/packager/testing/dockers/ArchLinux_Dockerfile @@ -3,6 +3,7 @@ FROM archlinux:latest # Install utilities, libraries, and dev tools. RUN pacman -Sy --needed --noconfirm \ core/which \ + c-ares \ gcc git python2 python3 # Install depot_tools. diff --git a/packager/testing/dockers/CentOS_Dockerfile b/packager/testing/dockers/CentOS_Dockerfile index 364945ad30..327581d3ec 100644 --- a/packager/testing/dockers/CentOS_Dockerfile +++ b/packager/testing/dockers/CentOS_Dockerfile @@ -3,7 +3,7 @@ FROM centos:8 # Install utilities, libraries, and dev tools. RUN yum install -y \ which \ - libatomic \ + c-ares-devel libatomic \ gcc-c++ git python2 python3 # Default to python3. diff --git a/packager/testing/dockers/Debian_Dockerfile b/packager/testing/dockers/Debian_Dockerfile index 2299a46318..cba5b5e31d 100644 --- a/packager/testing/dockers/Debian_Dockerfile +++ b/packager/testing/dockers/Debian_Dockerfile @@ -4,6 +4,7 @@ FROM debian:9 RUN apt-get update && apt-get install -y apt-utils RUN apt-get install -y \ curl \ + libc-ares-dev \ build-essential git python python3 # Install depot_tools. diff --git a/packager/testing/dockers/Fedora_Dockerfile b/packager/testing/dockers/Fedora_Dockerfile index 8438319fc3..63319f71c5 100644 --- a/packager/testing/dockers/Fedora_Dockerfile +++ b/packager/testing/dockers/Fedora_Dockerfile @@ -3,7 +3,7 @@ FROM fedora:34 # Install utilities, libraries, and dev tools. RUN yum install -y \ which \ - libatomic \ + c-ares-devel libatomic \ gcc-c++ git python2 # Default to python3. diff --git a/packager/testing/dockers/OpenSUSE_Dockerfile b/packager/testing/dockers/OpenSUSE_Dockerfile index 2a99f2e233..8059a1f920 100644 --- a/packager/testing/dockers/OpenSUSE_Dockerfile +++ b/packager/testing/dockers/OpenSUSE_Dockerfile @@ -3,6 +3,7 @@ FROM opensuse/leap:15 # Install utilities, libraries, and dev tools. RUN zypper in -y \ curl which \ + c-ares-devel \ gcc-c++ git python python3 # Install depot_tools. diff --git a/packager/testing/dockers/Ubuntu_Dockerfile b/packager/testing/dockers/Ubuntu_Dockerfile index a7ccf3cb2a..03b5be72cd 100644 --- a/packager/testing/dockers/Ubuntu_Dockerfile +++ b/packager/testing/dockers/Ubuntu_Dockerfile @@ -4,6 +4,7 @@ FROM ubuntu:18.04 RUN apt-get update && apt-get install -y apt-utils RUN apt-get install -y \ curl \ + libc-ares-dev \ build-essential git python python3 # Install depot_tools. diff --git a/packager/third_party/curl/curl.gyp b/packager/third_party/curl/curl.gyp index 27afa68dfb..86c8fe6ea0 100644 --- a/packager/third_party/curl/curl.gyp +++ b/packager/third_party/curl/curl.gyp @@ -37,10 +37,16 @@ 'HAVE_CONFIG_H', 'CURL_CA_BUNDLE="