Skip to content

Commit

Permalink
fix abseil setup on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Feb 20, 2024
1 parent 2bd05ad commit 9a21672
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
2 changes: 2 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ source:
- patches/0004-also-install-pkg-config-files-on-windows.patch
# install CMake metadata
- patches/0005-create-and-install-CMake-metadata.patch
# fix abseil setup on windows
- patches/0006-also-link-to-static-absl_flags_-on-windows.patch

build:
number: 0
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0001-do-not-mix-static-shared-builds.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 2fe3e37744c810590e631c01fb57133080fc5f46 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Thu, 2 Dec 2021 08:39:53 +1100
Subject: [PATCH 1/5] do not mix static & shared builds
Subject: [PATCH 1/6] do not mix static & shared builds

---
src/CMakeLists.txt | 20 ++++++++++----------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ab5c20be4a987d1cd6d2e472634f5e1b9c11211f Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Thu, 2 Dec 2021 10:05:12 +1100
Subject: [PATCH 2/5] do not build vendored abseil & libprotobuf-lite
Subject: [PATCH 2/6] do not build vendored abseil & libprotobuf-lite

ensure we can use shared builds of libprotobuf also on windows
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 428ac3758e24b1aeedec8e0568d128e2097d1646 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Sun, 11 Dec 2022 01:09:03 +1100
Subject: [PATCH 3/5] point to our libs / headers for windows in setup.py
Subject: [PATCH 3/6] point to our libs / headers for windows in setup.py

also do not risk building against bundled libs, nor
setting /MT for the MSVC static runtime libs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From f6ec12fe46a666940007cb205e715ee6f3916e97 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Mon, 12 Dec 2022 14:36:45 +1100
Subject: [PATCH 4/5] also install pkg-config files on windows
Subject: [PATCH 4/6] also install pkg-config files on windows

---
CMakeLists.txt | 4 +---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 366a1080b048a43452bdfb43968c5f2a44acdcf4 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Wed, 18 Jan 2023 19:44:15 +1100
Subject: [PATCH 5/5] create and install CMake metadata
Subject: [PATCH 5/6] create and install CMake metadata

---
CMakeLists.txt | 10 ++++++++++
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 64f7608bd0757387cee221df7014c9bdbe78585b Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <[email protected]>
Date: Tue, 20 Feb 2024 17:43:23 +1100
Subject: [PATCH 6/6] also link to static absl_flags_* on windows

---
python/setup.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/python/setup.py b/python/setup.py
index fb301ac..4366d1a 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -117,13 +117,21 @@ if os.name == 'nt':
]
elif True:
cflags = ['/std:c++17', '/MD', '/I' + os.environ["LIBRARY_INC"]]
+ # most of abseil can be built as shared, which ends up in one giant library
+ # called abseil_dll; the absl_flags_* libraries always stay static
+ absl_libs = [
+ "abseil_dll", "absl_flags", "absl_flags_commandlineflag", "absl_flags_commandlineflag_internal",
+ "absl_flags_config", "absl_flags_internal", "absl_flags_marshalling", "absl_flags_parse",
+ "absl_flags_private_handle_accessor", "absl_flags_program_name", "absl_flags_reflection",
+ "absl_flags_usage", "absl_flags_usage_internal",
+ ]
libs = [
# equivalent of -L$PREFIX/lib -lsentencepiece -lsentencepiece_train -lprotobuf-lite
os.environ["LIBRARY_LIB"] + f"\\{x}.lib"
# protobuf actually has the lib-prefix in the name also on windows;
# since libsentencepiece is static on windows, we also need _its_
# host dependencies for the link interface, i.e. also abseil
- for x in ["sentencepiece", "sentencepiece_train", "libprotobuf-lite", "abseil_dll"]
+ for x in ["sentencepiece", "sentencepiece_train", "libprotobuf-lite"] + absl_libs
]
else:
# build library locally with cmake and vc++.

0 comments on commit 9a21672

Please sign in to comment.