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

fix sysctlt compilation error on FreeBSD #27817

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Nov 11, 2019

This is regression caused by #27048 and build fails like:

[ 28%] Built target utilcodestaticnohost
/home/furt/git/coreclr/src/pal/src/misc/sysinfo.cpp:382:10: error: use of undeclared identifier 'sysctlnametomib'
    rc = sysctlnametomib("vm.swap_info", mib, &length);
         ^
[ 35%] Built target cee_dac
/home/furt/git/coreclr/src/pal/src/misc/sysinfo.cpp:390:18: error: use of undeclared identifier 'sysctl'
            rc = sysctl(mib, 3, &xsw, &length, NULL, 0);
                 ^
/home/furt/git/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/furt/git/coreclr/src/pal/src/misc/sysinfo.cpp:600:16: error: use of undeclared identifier 'sysctlbyname'
            || sysctlbyname("hw.l2cachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0
               ^
/home/furt/git/coreclr/src/pal/src/misc/sysinfo.cpp:601:16: error: use of undeclared identifier 'sysctlbyname'
            || sysctlbyname("hw.l1dcachesize", &cacheSizeFromSysctl, &sz, nullptr, 0) == 0;
[ 35%] Generating eventpipe/eventpipehelpers.cpp, eventpipe/dotnetruntime.cpp, eventpipe/dotnetruntimerundown.cpp, eventpipe/dotnetruntimestress.cpp, eventpipe/dotnetruntimeprivate.cpp

The problem is that FreeBSD has HAVE_SYSCONF and that seems mutually elusive in includes but later on used with different guard. Maybe it would be better to set HAVE_SYSCONF=0 on Linux if we want to avoid usage of it.

This is minimal change to fix compilation while preserving spirit of #27048.
Note that FreeBSD does not have vm.swap_info. We will probably need separate effort to find some equivalent.

cc: @omajid

@wfurt wfurt added the os-freebsd FreeBSD OS label Nov 11, 2019
@wfurt wfurt requested a review from janvorli November 11, 2019 19:34
@wfurt wfurt self-assigned this Nov 11, 2019
@omajid
Copy link
Member

omajid commented Nov 11, 2019

@wfurt Thanks for fixing this. Should we add FreeBSD (and/or other BSDs) to our CI system?

@wfurt
Copy link
Member Author

wfurt commented Nov 11, 2019

@wfurt Thanks for fixing this. Should we add FreeBSD (and/or other BSDs) to our CI system?

That is long story.
FreeBSD used to be there but unfortunately it was removed as there is no official Azure or .NET support.

@@ -31,9 +31,12 @@ Revision History:

#if HAVE_SYSCONF
// <unistd.h> already included above
#elif HAVE_SYSCTL
#endif
#if HAVE_SYSCTL && not defined(__linux__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use ! instead of not here and below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

@wfurt wfurt merged commit 02748cc into dotnet:freebsd_sysctl Nov 11, 2019
@wfurt wfurt mentioned this pull request Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os-freebsd FreeBSD OS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants