What is the FreeBSD situation?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Nov 3 02:43:22 UTC 2017


On Thursday, November 02, 2017 19:28:50 Walter Bright via Digitalmars-d 
wrote:
> On 11/2/2017 2:25 PM, Jonathan M Davis wrote:
> > On Thursday, November 02, 2017 13:46:11 Walter Bright via Digitalmars-d
> >
> > wrote:
> >> On 11/1/2017 10:11 PM, Jonathan M Davis wrote:
> >>> But we
> >>> don't currently have a way to version code for a particular version of
> >>> FreeBSD even if we wanted to.
> >>
> >> The FreeBSD version can be detected at runtime, and different code
> >> executed.
> >
> > Sure, but you can't actually compile different code based on the FreeBSD
> > version, and if a type or function API changes, then that doesn't work.
> > Wouldn't you get a linker error for the stuff that isn't actually
> > defined on the C side of things? If so, then you can't really provide
> > both the old and new versions of a function or type and switch between
> > code that uses one or the other based on the version of the OS at
> > runtime. You'd have to be able to have the source code differ depending
> > on the FreeBSD version.
> I know in Windows the imports can be dynamically loaded at runtime.

I thought that that was just when explicitly loading a .dll or .so file via
something like dlopen or LoadLibrary instead of linking against it, and you
normally link against system libraries rather than dlopening them. But
Windows is pretty weird about how it dynamically links stuff, so I could be
misunderstanding something in Windows' case. Regardless, it wouldn't be the
case with static linking, and there are cases where it's definitely
preferable to statically link.

So, I fully expect that there are times when being able to version the
source code based on the OS version (or the libc version if you're talking
about Linux) would be needed. However, I don't know if it's needed often
enough for the compiler to directly support it rather than using custom
version specifiers for those code bases that do. Technically, I think that
the versioning that they do in C/C++ for this sort of thing with #includes
is more or less equivalent to using custom version specifiers rather than
actually doing anything special with the compiler.

Regardless, it would be nice if we could avoid the need to statically
version any code in dmd, druntime, or Phobos based on OS version.

- Jonathan M Davis



More information about the Digitalmars-d mailing list