-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around upstream compiler bug (#956)
Closes #716. Ref georust/geo#1255 (comment). Note that this is the same underlying implementation as upstream geo in <georust/geo#1255>. However, the trait-based implementation hits this compiler regression <rust-lang/rust#128887>, <rust-lang/rust#131960>, which prevents from compiling in release mode on a stable Rust version. For some reason, the **function-based implementation** does not hit this regression, and thus allows building geoarrow without using latest nightly and a custom `RUSTFLAGS`. Note that it's only `GeometryTrait` and `GeometryCollectionTrait` that hit this compiler bug. Other traits can use the upstream impls.
- Loading branch information
1 parent
d61e866
commit b4bc4f0
Showing
12 changed files
with
79 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,9 +103,7 @@ jobs: | |
# - uses: actions/checkout@v4 | ||
# with: | ||
# submodules: "recursive" | ||
# # We use nightly for now so that we can pass RUSTFLAGS below to work around | ||
# # https://github.com/geoarrow/geoarrow-rs/issues/716 | ||
# - uses: dtolnay/rust-toolchain@nightly | ||
# - uses: dtolnay/rust-toolchain@stable | ||
# - uses: Swatinem/rust-cache@v2 | ||
# - uses: prefix-dev/[email protected] | ||
# with: | ||
|
@@ -118,6 +116,6 @@ jobs: | |
# echo "PKG_CONFIG_PATH=$(pwd)/build/.pixi/envs/default/lib/pkgconfig" >> "$GITHUB_ENV" | ||
# echo "LD_LIBRARY_PATH=$(pwd)/build/.pixi/envs/default/lib" >> "$GITHUB_ENV" | ||
# - name: Build benchmarks with no features | ||
# run: RUSTFLAGS="-Zinline-mir=no" cargo bench --no-run | ||
# run: cargo bench --no-run | ||
# - name: Build benchmarks with all features | ||
# run: RUSTFLAGS="-Zinline-mir=no" cargo bench --no-run --all-features | ||
# run: cargo bench --no-run --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,10 +50,7 @@ jobs: | |
|
||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
env: | ||
RUSTFLAGS: "-Zinline-mir=no" | ||
with: | ||
rust-toolchain: nightly | ||
target: ${{ matrix.platform.target }} | ||
# As of Nov 2024, it was necessary to manually specify -i 3.13 to get | ||
# maturin to find the executable. --find-interpreter did not find it. | ||
|
@@ -88,10 +85,7 @@ jobs: | |
|
||
- name: Build wheels - ${{ matrix.platform.target }} | ||
uses: PyO3/maturin-action@v1 | ||
env: | ||
RUSTFLAGS: "-Zinline-mir=no" | ||
with: | ||
rust-toolchain: nightly | ||
target: ${{ matrix.platform.target }} | ||
args: --release --out dist -i 3.9 -i 3.10 -i 3.11 -i 3.12 -i 3.13 -m python/geoarrow-io/Cargo.toml | ||
sccache: "true" | ||
|
@@ -124,10 +118,7 @@ jobs: | |
|
||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
env: | ||
RUSTFLAGS: "-Zinline-mir=no" | ||
with: | ||
rust-toolchain: nightly | ||
target: ${{ matrix.target }} | ||
args: --release --out dist -i 3.9 -i 3.10 -i 3.11 -i 3.12 -m python/geoarrow-io/Cargo.toml | ||
|
||
|
@@ -162,10 +153,8 @@ jobs: | |
# - name: Build wheels | ||
# uses: PyO3/maturin-action@v1 | ||
# with: | ||
# rust-toolchain: nightly | ||
# target: ${{ matrix.target }} | ||
# manylinux: musllinux_1_2 | ||
# TODO: update rustflags env | ||
# args: --release --out dist -i 3.9 -i 3.10 -i 3.11 -i 3.12 -i 3.13 -m python/geoarrow-io/Cargo.toml | ||
|
||
# - name: Install built wheel | ||
|
@@ -206,10 +195,8 @@ jobs: | |
# - name: Build wheels | ||
# uses: PyO3/maturin-action@v1 | ||
# with: | ||
# rust-toolchain: nightly | ||
# target: ${{ matrix.platform.target }} | ||
# manylinux: musllinux_1_2 | ||
# TODO: update rustflags env | ||
# args: --release --out dist -i 3.9 -i 3.10 -i 3.11 -i 3.12 -i 3.13 -m python/geoarrow-io/Cargo.toml | ||
|
||
# - uses: uraimo/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! Convert structs that implement geo-traits to [geo-types] objects. | ||
//! | ||
//! Note that this is the same underlying implementation as upstream [geo] in | ||
//! <https://github.com/georust/geo/pull/1255>. However, the trait-based implementation hits this | ||
//! compiler regression <https://github.com/rust-lang/rust/issues/128887>, | ||
//! <https://github.com/rust-lang/rust/issues/131960>, which prevents from compiling in release | ||
//! mode on a stable Rust version. For some reason, the **function-based implementation** does not | ||
//! hit this regression, and thus allows building geoarrow without using latest nightly and a | ||
//! custom `RUSTFLAGS`. | ||
//! | ||
//! Note that it's only `GeometryTrait` and `GeometryCollectionTrait` that hit this compiler bug. | ||
//! Other traits can use the upstream impls. | ||
use geo::{CoordNum, Geometry, GeometryCollection}; | ||
|
||
use geo_traits::to_geo::{ | ||
ToGeoLine, ToGeoLineString, ToGeoMultiLineString, ToGeoMultiPoint, ToGeoMultiPolygon, | ||
ToGeoPoint, ToGeoPolygon, ToGeoRect, ToGeoTriangle, | ||
}; | ||
use geo_traits::{GeometryCollectionTrait, GeometryTrait, GeometryType}; | ||
|
||
/// Convert any Geometry to a [`Geometry`]. | ||
/// | ||
/// Only the first two dimensions will be kept. | ||
pub fn geometry_to_geo<T: CoordNum>(geometry: &impl GeometryTrait<T = T>) -> Geometry<T> { | ||
use GeometryType::*; | ||
|
||
match geometry.as_type() { | ||
Point(geom) => Geometry::Point(geom.to_point()), | ||
LineString(geom) => Geometry::LineString(geom.to_line_string()), | ||
Polygon(geom) => Geometry::Polygon(geom.to_polygon()), | ||
MultiPoint(geom) => Geometry::MultiPoint(geom.to_multi_point()), | ||
MultiLineString(geom) => Geometry::MultiLineString(geom.to_multi_line_string()), | ||
MultiPolygon(geom) => Geometry::MultiPolygon(geom.to_multi_polygon()), | ||
GeometryCollection(geom) => Geometry::GeometryCollection(geometry_collection_to_geo(geom)), | ||
Rect(geom) => Geometry::Rect(geom.to_rect()), | ||
Line(geom) => Geometry::Line(geom.to_line()), | ||
Triangle(geom) => Geometry::Triangle(geom.to_triangle()), | ||
} | ||
} | ||
|
||
/// Convert any GeometryCollection to a [`GeometryCollection`]. | ||
/// | ||
/// Only the first two dimensions will be kept. | ||
pub fn geometry_collection_to_geo<T: CoordNum>( | ||
geometry_collection: &impl GeometryCollectionTrait<T = T>, | ||
) -> GeometryCollection<T> { | ||
GeometryCollection::new_from( | ||
geometry_collection | ||
.geometries() | ||
.map(|geometry| geometry_to_geo(&geometry)) | ||
.collect(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters