Skip to content

Commit

Permalink
Update darwin sdk and version (#87)
Browse files Browse the repository at this point in the history
Update darwin SDK  and minimum supported MacOS

Update SDK and min MacOS version to 10.14 when built on
Debian 10. Update the osxcross version used to compile to a
recent release. Change SDK artifacts to be hosted on GCP.

Co-authored-by: Ivan Fernandez Calvo <[email protected]>
Co-authored-by: Ivan Fernandez Calvo <[email protected]>
  • Loading branch information
3 people authored May 19, 2021
1 parent 65baa4e commit e96f6ca
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,43 @@ GOARM, PLATFORM_ID, CC, and CXX.
1. Build the images from the project's root with `make`.
1. Get a logon token for the container registry by visiting <https://docker.elastic.co:7000>.
1. Publish the images with `make push`.

## Packaging MacOS SDK

The osxcross repository used to cross compile for MacOSX has [instructions for packaging the SDK](https://github.com/tpoechtrager/osxcross#packaging-the-sdk).

The instructions for packaging the SDK on a Linux instance are:

1. Clone the [osxcross](https://github.com/tpoechtrager/osxcross) repo.
1. Install `clang`, `make`, `libssl-dev`, `lzma-dev`, `libxml2-dev`, `libbz2-dev`.
1. Download [Xcode from Apple](Download Xcode: https://developer.apple.com/download/more]).
1. Run `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.

### bzip2 issues

If the `gen_sdk_package_pbza.sh` script gives an error that reads:

```
Error while extracting archive:(Metadata): bzip2 support not compiled in. (Success)
```

A manual work-around is needed in order to create the SDK (other people have reported that installing `libbz2-dev` fixed this issue).

First edit `osxcross/tools/tools.sh` to remove the `trap` line from the `create_tmp_dir` function (currently line 264).

Then re-run `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.

Go to the tmp dir created in the build dir: `cd osxcross/build/tmp_<X>`.

Then run:
```
../../target/SDK/tools/bin/pbzx -n Content | cpio -i
cd ../..
XCODEDIR=osxcross/build/tmp_<X> ./tools/gen_sdk_package.sh
```

The SDK should be in the working directory.
The tmp dir can be safely deleted after this.

The SDKs should be uploaded into the `gs://obs-ci-cache` bucket on GCP (Google Cloud Platform).
This is accessible to authorized users in the `elastic-observability` project [here](https://console.cloud.google.com/storage/browser/obs-ci-cache).
24 changes: 23 additions & 1 deletion go1.16/darwin/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,31 @@ RUN \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
clang \
llvm \
cmake \
patch \
python \
libssl-dev \
libxml2-dev \
lzma-dev \
llvm-dev \
uuid-dev \
&& rm -rf /var/lib/apt/lists/*

ARG OSXCROSS_SDK_URL=https://s3.amazonaws.com/beats-files/deps/MacOSX10.11.sdk.tar.xz
{{if eq .DEBIAN_VERSION "10"}}
ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX10.14.sdk.tar.xz
ARG OSXCROSS_PATH=/usr/osxcross
ARG OSXCROSS_REV=8a716a43a72dab1db9630d7824ee0af3730cb8f9
ARG SDK_VERSION=10.14
ARG DARWIN_VERSION=17
ARG OSX_VERSION_MIN=10.14
{{ else }}
ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX10.11.sdk.tar.xz
ARG OSXCROSS_PATH=/usr/osxcross
ARG OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa
ARG SDK_VERSION=10.11
ARG DARWIN_VERSION=15
ARG OSX_VERSION_MIN=10.10
{{ end }}

RUN \
mkdir -p /tmp/osxcross && cd /tmp/osxcross \
Expand All @@ -27,6 +44,8 @@ RUN \
&& rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man"

ENV PATH $OSXCROSS_PATH/bin:$PATH
# Add osxcross libraries to the library PATH
ENV LD_LIBRARY_PATH /usr/osxcross/lib:$LD_LIBRARY_PATH

COPY rootfs /

Expand All @@ -36,11 +55,14 @@ RUN cd / \
&& file helloWorld \
&& file helloWorld | grep -c 'Mach-O 64-bit x86_64'

# MacOSX10.14 SDK does not have 32bits compiler
{{if ne .DEBIAN_VERSION "10"}}
RUN cd / \
&& o32-clang helloWorld.c -o helloWorld \
&& file helloWorld \
&& file helloWorld | grep -c 'Mach-O i386' \
&& rm helloWorld.c helloWorld
{{ end }}

# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
Expand Down

0 comments on commit e96f6ca

Please sign in to comment.