kolide / launcher

Osquery launcher, autoupdater, and packager
https://kolide.com/launcher
Other
505 stars 100 forks source link

Compiling on Xcode 15 fails due to link library bugs #1263

Open erikng opened 1 year ago

erikng commented 1 year ago

When trying to compile launcher and the extensions specifically I get warnings like this

ld: warning: '/private/var/folders/vp/dghn9qns23s7c6dsgnf569rr0000gn/T/go-link-2059784828/go.o' has malformed LC_DYSYMTAB, expected 129 undefined symbols to start at index 21372, found 244 undefined symbols starting at index 83

After googling, I discovered some issues on go repo:

Specifically, just today as I was researching, someone posted a potential fix in the build chain. https://github.com/golang/go/issues/61190#issuecomment-1650102794

I changed https://github.com/kolide/launcher/blob/main/pkg/make/builder.go#L512 to the following

            ldFlags = append(ldFlags, "-extldflags=-Wl,-ld64")

Building with go run cmd/make/make.go -targets=tables.ext -linkstamp --os darwin --arch amd64 -debug, I was able to build with only a single warning ld: warning: ignoring duplicate library '-lobjc'. This warning is also present without this change when using the makefile.

I don't think this is a tenable solution, but just wanted to document what I've done. I will still need to test the extensions on both arm and amd64 and see if they actually work.

erikng commented 1 year ago

Also of note, I tested this on the current release commit and the most recent commit on main.

This issue impacts both macOS Sonoma with Xcode Beta and macOS 13 x with the Xcode Beta and updated CLI Tools beta.

RebeccaMahany commented 1 year ago

I upgraded my xcode to 15 beta 4:

% clang -v
Apple clang version 15.0.0 (clang-1500.0.34.3)
Target: arm64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I confirmed after the upgrade that I see the same warnings as you when building launcher on main. Despite the warnings, it looks like the resulting launcher build works fine -- I'm not seeing any obvious issues, at least. Let us know if you notice any issues?

Thanks for researching + testing the fix -- sounds like we should keep an eye on the upstream Golang/Apple fixes too.

erikng commented 1 year ago

It compiles, but I was concerned that one of the many tables wouldn't work, or worse crash, so I didn't want to risk it.

erikng commented 1 year ago

Initial testing with these new flags are working on macOS 13 and macOS 14 beta. Apple Silicon and Intel.

allinu commented 1 year ago

I hava the same envirment, use the beta OS and Command Line Tools, and the vscode told me that The gopls server failed to initialize., i have seen the https://github.com/golang/go/issues/61190 but i still don't know how repair it.

directionless commented 1 year ago

Is this a warning, or an error?

If it's a warning, I'm disinclined to change anything until we see it in a non-beta release. I don't know if Apple or Go will fix this.

allinu commented 1 year ago

Recently updated gopls doesn't have the alert message anymore, probably fixed it, I'll add it when it comes up again after that, thanks!