Skip to contentSkip to conversation

osxkeychain: fix build with Rust

PATCH In review Johannes Schindelin via GitGitGadget 3 participants 3 messages Jun 17 – Jun 18 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 osxkeychain: fix build with Rust

From: Johannes Schindelin <[email protected]>

Without NO_RUST defined, the varint encoder/decoder lives in the RUST_LIB, which needs to be linked. Symptom:

cc [... -o contrib/credential/osxkeychain/git-credential-osxkeychain [...] Undefined symbols for architecture x86_64:
"_decode_varint", referenced from:

      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _load_cache_entry_block in libgit.a[x86_64][174](read-cache.o)
  "_encode_varint", referenced from:
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _do_write_index in libgit.a[x86_64][174](read-cache.o)

ld: symbol(s) not found for architecture x86_64

While it is curious why these functions are needed at all (osxkeychain does not read or write the index), the compile error is a real problem.

Instead of trying to play games to add GITLIBS while filtering out common-main.o, replace the $(LIB_FILE) $(EXTLIBS) construct with the much shorter $(LIBS) construct that _already_ filters out common-main.o and adds the Rust library when needed.

---
osxkeychain: fix build with Rust

I ran into this when trying to build Microsoft Git v2.55.0-rc0. This seems to be similar in spirit to
https://lore.kernel.org/git/[email protected]/
but the latter seems not to have gained traction. This build failure is a hard regression in v2.55.0, though.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2154%2Fdscho%2Fosxkeychain-vs-rust-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2154/dscho/osxkeychain-vs-rust-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2154

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 0976a69b4c..1cec251f43 100644
@@ -4074,7 +4074,7 @@ contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
 
 contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) GIT-LDFLAGS
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
-		$(filter %.o,$^) $(LIB_FILE) $(EXTLIBS) -framework Security -framework CoreFoundation
+		$(filter %.o,$^) $(LIBS) -framework Security -framework CoreFoundation
 
 contrib/credential/osxkeychain/git-credential-osxkeychain.o: contrib/credential/osxkeychain/git-credential-osxkeychain.c GIT-CFLAGS
 	$(QUIET_LINK)$(CC) -o $@ -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<

base-commit: 0fae78c9d55efe705877ea537fe42c59164ccd94

Signature · 1 line
gitgitgadget
#1 lore raw

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 25 lines · writes:

From: Johannes Schindelin <[email protected]>

Without NO_RUST defined, the varint encoder/decoder lives in the RUST_LIB, which needs to be linked. Symptom:

cc [... -o contrib/credential/osxkeychain/git-credential-osxkeychain [...] Undefined symbols for architecture x86_64:
"_decode_varint", referenced from:

      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _load_cache_entry_block in libgit.a[x86_64][174](read-cache.o)
  "_encode_varint", referenced from:
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _do_write_index in libgit.a[x86_64][174](read-cache.o)

ld: symbol(s) not found for architecture x86_64

While it is curious why these functions are needed at all (osxkeychain does not read or write the index), the compile error is a real problem.

Quoted 7 lines

Instead of trying to play games to add GITLIBS while filtering out common-main.o, replace the $(LIB_FILE) $(EXTLIBS) construct with the much shorter $(LIBS) construct that _already_ filters out common-main.o and adds the Rust library when needed.

---

Hmph, we do not build this at GitHub Actions based CI? Just being curious.

Let me take this directly to 'master' before tagging -rc1. Thanks.

Quoted 1 line

osxkeychain: fix build with Rust

#2 lore raw
Quoted 33 lines · Junio C Hamano

"Johannes Schindelin via GitGitGadget" <[email protected]>

Quoted 30 lines · writes:

From: Johannes Schindelin <[email protected]>

Without NO_RUST defined, the varint encoder/decoder lives in the RUST_LIB, which needs to be linked. Symptom:

cc [... -o contrib/credential/osxkeychain/git-credential-osxkeychain [...] Undefined symbols for architecture x86_64:
"_decode_varint", referenced from:

      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_untracked_extension in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _read_one_dir in libgit.a[x86_64][63](dir.o)
      _load_cache_entry_block in libgit.a[x86_64][174](read-cache.o)
  "_encode_varint", referenced from:
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_untracked_extension in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _write_one_dir in libgit.a[x86_64][63](dir.o)
      _do_write_index in libgit.a[x86_64][174](read-cache.o)

ld: symbol(s) not found for architecture x86_64

While it is curious why these functions are needed at all (osxkeychain does not read or write the index), the compile error is a real problem.

Instead of trying to play games to add GITLIBS while filtering out common-main.o, replace the $(LIB_FILE) $(EXTLIBS) construct with the much shorter $(LIBS) construct that _already_ filters out common-main.o and adds the Rust library when needed.

Quoted 5 lines
Quoted 2 lines

---

Hmph, we do not build this at GitHub Actions based CI? Just being curious.

We build it with Meson, but not with our Makefile. And in Meson things are working alright.

Quoted 1 line

Let me take this directly to 'master' before tagging -rc1. Thanks.

Makes sense.

Patrick