Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update darwin sdk and version #87

Merged
merged 16 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,40 @@ 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the upload to the bucket should be also added in this section?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

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