Skip to content

Rebuild gitlab-elasticsearch-indexer if icu4c pkg-config flags change

Stan Hu requested to merge sh-fix-icu4c-elasticsearch into main

When the version of the icu4c library changes, users have to run go clean -cache to rebuild gitlab-elasticsearch-indexer. That is required because the gitlab.com/lupine/icu library uses the cgo pkg-config build tag, which runs pkg-config and caches the result in the Go module cache.

In macOS, the path of the include files changes with each upgrade. For example, a recent upgrade changed from /opt/homebrew/Cellar/icu4c/71.1/include to /opt/homebrew/Cellar/icu4c/72.1/include. As a result, the cached code was looking in the 71.1 directory and failing to build.

As https://github.com/golang/go/issues/24544 explains, another way to solve this issue would be to force a rebuild via go build -a. We can do this by tracking the state of the pkg-config flags in a .icu_flags file. If they change, then we can force a rebuild.

Relates to gitlab-development-kit#1450 (closed)

Edited by Stan Hu

Merge request reports