Closed a2379 closed 2 months ago
Also does not seem to expand CPU architecture features either, like x86-64
.
What is the precise semantic meaning of the identifiers? This question needs to be answered first before one can decide whether is certain feature flag should be set or not.
Agree with @mnieper, the list in the appendix is just suggestions and not formally specified. Was there a SRFI for this?
Not sure why we'd want linux-gnu
instead of linux
. Plan9 is not posix
.
Anyway, added the missing architecture feature for now.
https://github.com/cpredef/predef is a great resource for this stuff. But underscores the point that it's not an exact science.
It doesn't need to be precise to be useful. If I have a Scheme script that needs to change its behavior based on the OS it's running on, having a general identifier like openbsd
or linux
is sufficient.
I agree that linux-gnu
is not necessary, I guess they just wrote that in the spec to avoid the GNU/Linux debate.
It doesn't need to be precise to be useful. If I have a Scheme script that needs to change its behavior based on the OS it's running on, having a general identifier like
openbsd
orlinux
is sufficient.I agree that
linux-gnu
is not necessary, I guess they just wrote that in the spec to avoid the GNU/Linux debate.
There is a huge difference between a GNU/Linux system and, say, an Android system with a Linux kernel. Thus, it makes a lot of sense to differentiate further. For example, when the Scheme system offers an exec
-like command, the feature flags (if sufficiently specified) could tell the applications which typical programs are available to execute. A generic linux
wouldn't help much here.
There is a huge difference between a GNU/Linux system and, say, an Android system with a Linux kernel.
The OS is the feature identifier, not the kernel. Android would have its own feature identifier, not linux
IMO.
It may be helpful to differentiate a Linux system with GNU userland/glibc vs busybox/musl, but I think the broader feature identifiers are a good starting point.
Binaries are built for CPU + kernel + libc. The only GNU piece here is glibc.
At runtime, there's uname()
and /etc/os-release
. I imagine there are gotchas for both.
Binaries are built for CPU + kernel + libc. The only GNU piece here is glibc.
Yes, but a Scheme scripts may interact with userland through subprocesses, and GNU tools have a number of extensions that incompatible with POSIX tools.
At runtime, there's
uname()
and/etc/os-release
. I imagine there are gotchas for both.
Yes but having an abstraction would be helpful, especially in a language like Scheme where OS details are usually abstracted over.
cond-expand
is the wrong tool for finding your way around the userland. If you need GNU tar, try tar --version
.
The underlying principle is that cond-expand
can be used for both compiled and interpreted Scheme code. The concerns that apply to compiled Scheme programs (across the full range of available of Scheme implementations) are pretty much the same ones that apply to compiled C programs.
For example, a built program can be copied to another computer with compatible kernel and libc but a different userland. Or a program built on Windows 7 can be run on Wine/Linux or Wine/MacOS.
If you need tar, use (chibi tar)
! :wink:
Yes, there are limitations to cond-expand
(especially when it comes to cross compiling) but it's better than nothing. System interfaces should be abstracted into portable libraries, but until these are available you often have no other choice than to use cond-expand
.
That said, Chibi has all of these features except posix
and the gnu-
linux variant because I'm unclear as to both the motivation and semantics of those. If there are developments in that area we can reconsider, but in the meantime am closing this.
The R7RS
(features)
specification suggests thatlinux-gnu
can be used as acond-expand
feature identifier. Appendix B specifiesposix
as well. But neither are provided by chibi.I think the the
linux
feature should be set if running on Linux,linux-gnu
only if_GNU_SOURCE
is set, andposix
for all POSIX systems (and maybe Plan 9?).