Fix port/pg_iovec.h building extensions on x86_64-darwin
When building pg_cron [1]https://hydra.nixos.org/build/276421287/nixlog/1 or pg_hll [2]https://hydra.nixos.org/build/276419879/nixlog/1 for PG 17 on x86_64-darwin, we
encounter the following build failure in nixpkgs:
/nix/store/2clw9wg933c40f871d8iqbl909lg2yis-postgresql-17.0-dev/include/server/port/pg_iovec.h:71:12:
error: comparison of integers of different signs: 'ssize_t' (aka 'long')
and 'const size_t' (aka 'const unsigned long') [-Werror,-Wsign-compare]
if (part < iov[i].iov_len)
~~~~ ^ ~~~~~~~~~~~~~~
/nix/store/2clw9wg933c40f871d8iqbl909lg2yis-postgresql-17.0-dev/include/server/port/pg_iovec.h:110:12:
error: comparison of integers of different signs: 'ssize_t' (aka 'long')
and 'const size_t' (aka 'const unsigned long') [-Werror,-Wsign-compare]
if (part < iov[i].iov_len)
~~~~ ^ ~~~~~~~~~~~~~~
2 errors generated.
The attached patch fixes those.
Hopefully this can make it into the minor release next week.
Best,
Wolfgang
[1]: https://hydra.nixos.org/build/276421287/nixlog/1
[2]: https://hydra.nixos.org/build/276419879/nixlog/1
Attachments:
0001-Fix-build-on-x86_64-darwin.patchtext/x-patch; charset=UTF-8; name=0001-Fix-build-on-x86_64-darwin.patchDownload+2-3
On Fri, Nov 08, 2024 at 08:08:06PM +0100, Wolfgang Walther wrote:
@@ -68,7 +68,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
}
sum += part;
offset += part;
- if (part < iov[i].iov_len)
+ if ((size_t) part < iov[i].iov_len)
return sum;
}
return sum;
@@ -107,7 +107,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
}
sum += part;
offset += part;
- if (part < iov[i].iov_len)
+ if ((size_t) part < iov[i].iov_len)
return sum;
}
return sum;
This looks correct to me. At this point in the code, we know that part >=
0, so casting it to an unsigned long ought to be okay.
--
nathan
Here is a new version of the patch with an updated commit message. The
cfbot results [0]https://cirrus-ci.com/build/6599760059039744 look good, so I plan to commit this one shortly unless
someone objects.
[0]: https://cirrus-ci.com/build/6599760059039744
--
nathan
Attachments:
v2-0001-Fix-sign-compare-warnings-in-pg_iovec.h.patchtext/plain; charset=us-asciiDownload+2-4
On Fri, Nov 08, 2024 at 03:20:00PM -0600, Nathan Bossart wrote:
Here is a new version of the patch with an updated commit message. The
cfbot results [0] look good, so I plan to commit this one shortly unless
someone objects.
Committed.
--
nathan
On Sat, Nov 9, 2024 at 8:08 AM Wolfgang Walther <walther@technowledgy.de> wrote:
When building pg_cron [1] or pg_hll [2] for PG 17 on x86_64-darwin, we
encounter the following build failure in nixpkgs:
Out of curiosity, is nixos deliberately using an old macOS deployment
target or SDK, 10.something? I'm just wondering if our feature
detection is working correctly on macOS/x86, because I'd expect real
preadv/pwritev to be there from 11 onwards, and 11 is already out of
support by Apple.
On Sat, Nov 09, 2024 at 11:26:44AM +1300, Thomas Munro wrote:
Out of curiosity, is nixos deliberately using an old macOS deployment
target or SDK, 10.something? I'm just wondering if our feature
detection is working correctly on macOS/x86, because I'd expect real
preadv/pwritev to be there from 11 onwards, and 11 is already out of
support by Apple.
It appears to be working for longfin [0]https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=longfin&dt=2024-11-08%2021%3A36%3A02&stg=configure.
--
nathan
Thomas Munro:
Out of curiosity, is nixos deliberately using an old macOS deployment
target or SDK, 10.something? I'm just wondering if our feature
detection is working correctly on macOS/x86, because I'd expect real
preadv/pwritev to be there from 11 onwards, and 11 is already out of
support by Apple.
There has been a lot of work on the macOS SDK in nixpkgs lately, but it
seems that the default for x86-64 is still v10 [1]https://nixos.org/manual/nixpkgs/unstable/#sec-darwin, yes:
x86_64-darwin uses the 10.12 SDK by default, but some software is not
compatible with that version of the SDK. In that case, the 11.0 SDK
used by aarch64-darwin is available for use on x86_64-darwin. [...]
It seems like the goal is to bump x86-64 to v11 in the next release
cycle [2]https://discourse.nixos.org/t/on-the-future-of-darwin-sdks-or-how-you-can-stop-worrying-and-put-the-sdk-in-build-inputs/50574/11.
Best,
Wolfgang
[1]: https://nixos.org/manual/nixpkgs/unstable/#sec-darwin
[2]: https://discourse.nixos.org/t/on-the-future-of-darwin-sdks-or-how-you-can-stop-worrying-and-put-the-sdk-in-build-inputs/50574/11
https://discourse.nixos.org/t/on-the-future-of-darwin-sdks-or-how-you-can-stop-worrying-and-put-the-sdk-in-build-inputs/50574/11