grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

Usage of sys/sysctl.h #479

Closed umlaeute closed 4 years ago

umlaeute commented 4 years ago

Forwarding a bug that was reported against the Debian package, but which i believe is of general concern:

Version 2.32 of glibc will not ship the sysctl() function and the <sys/sysctl.h> header any more. sysctl itself has been deprecated in Linux and will be removed. faust is using it, so will start FTBFS when distributions switch to glibc-2.32.

glibc-2.32 was released last week, so i guess problems will start to appear sooner rather than later.

sletz commented 4 years ago

Thanks. Can you point out which usage of <sys/sysctl.h> causes problems?

umlaeute commented 4 years ago

afaik, the entire file sys/sysctl.h will not be available if you have glibc>=2.32 installed.

so any use will just result in a FTBFS.

sletz commented 4 years ago

I don't see really problematic cases here: that https://github.com/grame-cncm/faust/search?q=sysctl.h&unscoped_q=sysctl.h

Do you see any?

umlaeute commented 4 years ago

well: https://github.com/grame-cncm/faust/blob/01bbb3544584eac8e4e32aa71f13aef0c25649d4/architecture/faust/dsp/llvm-dsp-multi.h#L31

and https://github.com/grame-cncm/faust/blob/4762c9cb49f0d6b19ae6291cc858eceae6210dd4/architecture/scheduler.cpp#L34

this seems to be an unconditional include (not protected by an HAVE_SYS_SYSCTL_H guard) on linux systems. if the file is not there i expect this to fail. (but haven't tested)

umlaeute commented 4 years ago

but if course i don't really know which files are actually used in which contexts. if i remove sys/sysctl.h from my filesystem, i can still compile faust itself.

but i have no idea if using faust might trigger the inclusion of (e.g.) scheduler.cpp (with whatever options)

umlaeute commented 4 years ago

a well, here goes:

$ sudo find /usr/include/ -path "*sys/sysctl.h" -delete
$ faust2jackconsole --scheduler lowCut.dsp
lowCut.dsp.cpp:17567:10: fatal error: sys/sysctl.h: No such file or directory
17567 | #include <sys/sysctl.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

if i remove the #include <sys/sysctl.h> line form scheduler.cpp, the compilation succeeds.

i guess the include is really only needed on __APPLE__, where you call sysctlbyname().

i don't know about llvm-dsp-multi.h (and won't investigate further, as i think you know the code better than me)

sletz commented 4 years ago

Right. Should be fixed in https://github.com/grame-cncm/faust/commit/1b907100c7d87f5a149af4d67941ac35cf7b917f

umlaeute commented 3 years ago

just noticed that faust doesn't even compile on GNU/Hurd, because of this line: https://github.com/grame-cncm/faust/blob/8e766001e2f1341e07a3f80fe944701c84362461/compiler/generator/tools.cpp#L88-L91

is there any specific reason to include sys/sysctl.h here? it doesn't seem to be used at all.

@sletz should i open a separate (new) ticket?

sletz commented 3 years ago

Probably a typo,#include <sys/sysctl.h> removed on my local version. Will push soon.

umlaeute commented 3 years ago

actually you will need to include a header file for the definition of size_t.

so you could just replace the includes:

--- faust-2.30.5.orig/compiler/generator/tools.cpp
+++ faust-2.30.5/compiler/generator/tools.cpp
@@ -87,7 +87,7 @@ size_t cache_line_size()

 #else
 #warning Unrecognized platform
-#include <sys/sysctl.h>
+#include <cstddef>
 size_t cache_line_size()
 {
     return 0;
sletz commented 3 years ago

OK, thanks.