Skip to content

Commit

Permalink
fix: Fix crash in static-linked linux builds
Browse files Browse the repository at this point in the history
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 shaka-project#996

Change-Id: Ib4a9eb939813fd165727788726459ef4adf3fc4d
  • Loading branch information
joeyparrish committed Oct 14, 2021
1 parent 9fc3ee1 commit e2d66b3
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 5 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/custom-actions/build-packager/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
7 changes: 5 additions & 2 deletions docs/source/build_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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
```
Expand All @@ -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
```
Expand All @@ -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'
```
Expand All @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion packager/testing/dockers/Alpine_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packager/testing/dockers/ArchLinux_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packager/testing/dockers/CentOS_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packager/testing/dockers/Debian_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packager/testing/dockers/Fedora_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packager/testing/dockers/OpenSUSE_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions packager/testing/dockers/Ubuntu_Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions packager/third_party/curl/curl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@
'HAVE_CONFIG_H',
'CURL_CA_BUNDLE="<!(config/linux/find_curl_ca_bundle.sh)"',
'USE_OPENSSL',
'USE_ARES',
],
'include_dirs': [
'config/linux',
],
'link_settings': {
'libraries': [
'-lcares',
],
},
},
}],
['OS == "mac"', {
Expand Down

0 comments on commit e2d66b3

Please sign in to comment.