Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Include sys/sysctl.h in sysinfo.cpp for FreeBSD #27827

Closed
wants to merge 1 commit into from

Conversation

am11
Copy link
Member

@am11 am11 commented Nov 12, 2019

Regressed since #27048.

While this header is not required for GetSystemInfo by FreeBSD either, it is required for sysctl, sysctlnametomib and sysctlbyname:

https://www.freebsd.org/cgi/man.cgi?query=sysctlnametomib&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE&arch=default&format=html

build error:

[  5%] Building CXX object src/pal/src/CMakeFiles/coreclrpal.dir/misc/sysinfo.cpp.o
[  6%] Building CXX object src/md/compiler/CMakeFiles/mdcompiler_dac.dir/helper.cpp.o
[  6%] Building CXX object src/md/compiler/CMakeFiles/mdcompiler_crossgen.dir/emit.cpp.o
/home/am11/projects/dotnet/coreclr/src/pal/src/misc/sysinfo.cpp:382:10: error: use of undeclared identifier 'sysctlnametomib'
    rc = sysctlnametomib("vm.swap_info", mib, &length);
         ^
/home/am11/projects/dotnet/coreclr/src/pal/src/misc/sysinfo.cpp:390:18: error: use of undeclared identifier 'sysctl'
            rc = sysctl(mib, 3, &xsw, &length, NULL, 0);
                 ^
/home/am11/projects/dotnet/coreclr/src/pal/src/misc/sysinfo.cpp:599:30: error: use of undeclared identifier 'sysctlbyname'
        const bool success = sysctlbyname("hw.l3cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
                             ^
/home/am11/projects/dotnet/coreclr/src/pal/src/misc/sysinfo.cpp:600:16: error: use of undeclared identifier 'sysctlbyname'
            || sysctlbyname("hw.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
               ^
/home/am11/projects/dotnet/coreclr/src/pal/src/misc/sysinfo.cpp:601:16: error: use of undeclared identifier 'sysctlbyname'
            || sysctlbyname("hw.l1dcachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0;
               ^
5 errors generated.
--- src/pal/src/CMakeFiles/coreclrpal.dir/misc/sysinfo.cpp.o ---
*** [src/pal/src/CMakeFiles/coreclrpal.dir/misc/sysinfo.cpp.o] Error code 1

make[2]: stopped in /usr/home/am11/projects/dotnet/coreclr/bin/obj/FreeBSD.x64.Release
1 error

cc @omajid, @wfurt: i was building master branches to run System.Diagnostics.Process tests in CoreFX and encountered this error. Otherwise build succeeds on FreeBSD 12.

@wfurt
Copy link
Member

wfurt commented Nov 12, 2019

seems just like #27827 :)
I'm wondering if we should also guard rest of the code with HAVE_SYSCTLBYNAME instead of HAVE_SYSCTL so they are in balance.

@am11
Copy link
Member Author

am11 commented Nov 12, 2019

Ops, didn't realize #27819 is already fixing it. :)

HAVE_SYSCTLBYNAME instead of HAVE_SYSCTL

I think it makes sense as in this context, HAVE_SYSCTLBYNAME is more reliable macro to determine whether sys/sysctl.h should be included. It is also used in another file where sysctlnametomib is used.

@am11 am11 closed this Nov 12, 2019
@am11 am11 mentioned this pull request Nov 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants