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

build: refactor install_ffmpeg.sh, add macos --> linux support #2886

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

iameli
Copy link
Contributor

@iameli iameli commented Oct 9, 2023

This implements macOS --> Linux cross-compilation support for hacking on go-livepeer in livepeer-in-a-box.

Just M1/arm64 support for the moment. I assume the process for adding amd64 would be very similar, but I don't have one handy to test.

Specific changes:

  • Refactored install_ffmpeg.sh a bit. It will now have four variables defined in all cases: BUILDOS, BUILDARCH, GOOS, and GOARCH. This makes it much easier to implement conditional checks later on.
  • The Makefile has those variables now also.
  • Added a new conditional block for darwin-arm64 --> linux-arm64 compilation.

Makefile Outdated
ifeq ($(GOARCH),arm64)
LLVM_PATH ?= /opt/homebrew/opt/llvm/bin
SYSROOT ?= /tmp/sysroot-aarch64-linux-gnu
cgo_cflags += --target=aarch64-linux-gnu -Wno-error=unused-command-line-argument
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I swear I tried 100 different methods and nothing I tried was able to get -fuse-ld=$(LLVM_PATH)/ld.lld passed to clang when it was running in linker mode consistently. So now we pass it to every clang command, and -Wno-error=unused-command-line-argument just ignores it when we're compiling rather than linking. I don't know. There's probably a better way, but no combination of -ldflags, -extld, -extldflags, LDFLAGS, and a few others was making it happen for me.

@iameli iameli force-pushed the eli/mac-to-linux-cross branch 7 times, most recently from d137d4c to 7ebd45d Compare October 13, 2023 20:49
@iameli iameli requested a review from leszko October 18, 2023 00:28

- GOOS: linux
GOARCH: arm64
runner: ubuntu-latest-m
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need runner to be part of matrix if it's always the same ubuntu-latest-m?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to leave it for now - in the process of doing this I needed to adjust the runners per-job quite a bit; it's entirely possible the next build we do will have to do the same thing

.github/workflows/build.yaml Outdated Show resolved Hide resolved
install_ffmpeg.sh Show resolved Hide resolved
@emranemran emranemran self-requested a review October 18, 2023 16:28
@iameli iameli merged commit 6b3c218 into master Oct 25, 2023
18 checks passed
@iameli iameli deleted the eli/mac-to-linux-cross branch October 25, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants