Bug 234180 - getrandom linking problem due to missing macros in sys/random.h
Summary: getrandom linking problem due to missing macros in sys/random.h
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-12-19 21:03 UTC by Ralf van der Enden
Modified: 2019-01-17 23:36 UTC (History)
2 users (show)

See Also:


Attachments
Add missing macros for C++ linking (357 bytes, text/plain)
2018-12-19 21:03 UTC, Ralf van der Enden
no flags Details
Add missing macros for C++ linking (new patch without cdefs.h include) (315 bytes, patch)
2018-12-24 12:46 UTC, Ralf van der Enden
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf van der Enden 2018-12-19 21:03:27 UTC
Created attachment 200284 [details]
Add missing macros for C++ linking

While testing a new version of an application I ran into a linking error. It appears c++ sources including sys/random.h fail linking due to a missing reference to getrandom. This is caused by missing __BEGIN_DECLS/__END_DECLS in sys/random.h

Supplied patch remedies the problem, but it might need review by a C++ guru (which I'm not).
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2018-12-19 21:19:22 UTC
The cdefs include isn't needed (it's in the wrong place, too, but it's redundant with the sys/types include already present in the right place at top of file).  Otherwise, adding the C++ demangling seems reasonable to me — at least in the sense that it is consistent with other sys/ headers.

For 12.0, can you work around the issue by adding 'extern "C" {' around the #include?
Comment 2 Ralf van der Enden 2018-12-19 21:43:37 UTC
I can confirm adding extern "C" {} around it works fine. The software I was trying to build is still in alpha, so no immediate need for a proper fix.

I am curious though. Will this be fixed in 12.0-RELEASE-p? update or only in 12-STABLE ? 

Thanks for your quick response.
Comment 3 Conrad Meyer freebsd_committer freebsd_triage 2018-12-19 21:51:21 UTC
I can't speak to that; I don't know much about FreeBSD's stable/releng process.
Comment 4 Ralf van der Enden 2018-12-24 12:46:52 UTC
Created attachment 200452 [details]
Add missing macros for C++ linking (new patch without cdefs.h include)
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-12-24 19:37:37 UTC
A commit references this bug:

Author: cem
Date: Mon Dec 24 19:37:10 UTC 2018
New revision: 342398
URL: https://svnweb.freebsd.org/changeset/base/342398

Log:
  Enable sys/random.h #include from C++

  And bump __FreeBSD_version, just in case.

  PR:		234180
  Submitted by:	Ralf van der Enden <tremere AT cainites.net>
  MFC after:	5 days

Changes:
  head/sys/sys/param.h
  head/sys/sys/random.h
Comment 6 Conrad Meyer freebsd_committer freebsd_triage 2018-12-24 19:38:20 UTC
Thanks!  Ok, that's the CURRENT part; someone else will handle MFC'ing it into stable/12.
Comment 7 commit-hook freebsd_committer freebsd_triage 2019-01-17 23:23:32 UTC
A commit references this bug:

Author: brooks
Date: Thu Jan 17 23:22:56 UTC 2019
New revision: 343126
URL: https://svnweb.freebsd.org/changeset/base/343126

Log:
  MFC r342398:

  Enable sys/random.h #include from C++

  And bump __FreeBSD_version, just in case.

  PR:		234180
  Submitted by:	Ralf van der Enden <tremere AT cainites.net>

Changes:
_U  stable/12/
  stable/12/sys/sys/param.h
  stable/12/sys/sys/random.h
Comment 8 Brooks Davis freebsd_committer freebsd_triage 2019-01-17 23:36:07 UTC
Merged to 12-STABLE.