bazel-contrib / bazel-contrib/rules_go

cgo: Generated header files are empty

Open
#2,878 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
762
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?
0.27.0

### What version of gazelle are you using?
0.23.0

### What version of Bazel are you using?
4.0.0

### Does this issue reproduce with the latest releases of all the above?
Yes

### What operating system and processor architecture are you using?
macOS Catalina, Intel

### Any other potentially useful information about your toolchain?
Currently using Go 1.16.2

### What did you do?
In [this repo](https://github.com/TheOpenDictionary/odict/tree/39800332c1102a3bbcfa16ec8987952a4f4d1ea3), I attempted to build the Java library using `bazel build java`, which connects to CGo via JNI. While this command worked previously, after updating to the latest rule version, the bridging header generated by cgo is empty. It's also, for some reason, symlinked to `bazel-out/darwin-fastbuild-ST-b8cfed987b33/bin/external/org_golang_x_sys/unix/unix_/_cgo_install.h`.

### What did you expect to see?
Expected the code to compile, as before

### What did you see instead?
The generated cgo header is empty and symlinked to a golang dependency folder. Buidling the cgo bridge directly (via `bazel build //bridge:archive`), generates a local `_cgo_install.h` in `bazel-out` with all the correct code. It just seems the symlink is messed up. Curious if this issue has anything to do with #2445 that landed recently.

Contributor guide

Open the contributing guide

Research direction

Reproduce with `bazel build java` from the linked repository, then compare it with `bazel build //bridge:archive`. Inspect how the generated cgo bridging header and `_cgo_install.h` are symlinked under `bazel-out`, especially the unexpected `external/org_golang_x_sys/unix/unix_` path. Done means the generated header contains the expected code and the Java library builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.