Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 649178 - sys-apps/openrc-0.35: rc.c:349:6: error: implicit declaration of function 'getline' [-Werror=implicit-function-declaration]
Summary: sys-apps/openrc-0.35: rc.c:349:6: error: implicit declaration of function 'ge...
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
Depends on:
Reported: 2018-03-01 13:08 UTC by Stephan Hartmann
Modified: 2019-10-11 15:23 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---

build log (build.log,30.25 KB, text/x-log)
2018-03-01 13:08 UTC, Stephan Hartmann
FreeBSD-posix.patch (FreeBSD-posix.patch,239 bytes, patch)
2018-03-04 00:27 UTC, William Hubbs
Details | Diff
FreeBSD.patch (FreeBSD.patch,252 bytes, patch)
2018-05-07 22:13 UTC, William Hubbs
Details | Diff
freebsd.patch (freebsd.patch,246 bytes, patch)
2018-05-09 17:50 UTC, William Hubbs
Details | Diff
ncurses.pc (ncurses.pc,465 bytes, text/plain)
2018-06-21 21:47 UTC, William Hubbs
ncurses-gentoo.pc (ncurses-gentoo.pc,537 bytes, text/plain)
2018-06-21 21:53 UTC, William Hubbs

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Hartmann 2018-03-01 13:08:11 UTC
Created attachment 521550 [details]
build log

Portage 2.3.24 (python 2.7.14-final-0, default/bsd/fbsd/amd64/11.1, gcc-6.4.0, freebsd-lib-11.1-r1, 11.1_p2-Gentoo amd64)
System uname: FreeBSD-11.1_p2-Gentoo-amd64-64bit-ELF
KiB Mem:    20815984 total
KiB Swap:          0 total
Timestamp of repository gentoo: Thu, 01 Mar 2018 10:30:01 +0000
Head commit of repository gentoo: 86d798b17ab1c74f1255184e269867dcfecc9798
sh sh
ld GNU ld (Gentoo 2.29.1 p3) 2.29.1
app-shells/bash:         4.4_p19::gentoo
dev-lang/perl:           5.26.1-r1::gentoo
dev-lang/python:         2.7.14-r1::gentoo
dev-util/pkgconfig:      0.29.2::gentoo
sys-apps/baselayout:     2.4.1-r2::gentoo
sys-apps/openrc:         0.34.11::gentoo
sys-devel/autoconf:      2.69-r4::gentoo
sys-devel/automake:      1.15.1-r1::gentoo
sys-devel/binutils:      2.29.1-r1::gentoo, 9999::gentoo
sys-devel/gcc:           6.4.0-r1::gentoo
sys-devel/gcc-config:    1.9.1::gentoo
sys-devel/libtool:       2.4.6-r4::gentoo
sys-devel/make:          4.2.1-r2::gentoo
sys-freebsd/freebsd-lib: 11.1-r1::gentoo (virtual/os-headers)

    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://
    priority: -1000
    sync-rsync-verify-metamanifest: no

ACCEPT_KEYWORDS="amd64-fbsd ~amd64-fbsd"
CFLAGS="-O2 -pipe -mtune=generic"
CONFIG_PROTECT="/boot/device.hints /etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -pipe -mtune=generic"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs chflags config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news nodoc noinfo parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersync"
FFLAGS="-O2 -pipe"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
USE="acl amd64-fbsd berkdb crypt cxx dri gdbm iconv ipv6 modules multilib ncurses nls oss pam pcre readline ssl tcpd unicode xattr zlib" ABI_X86="64" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="FreeBSD" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse" KERNEL="FreeBSD" L10N="de en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7" RUBY_TARGETS="ruby22 ruby23" USERLAND="BSD" VIDEO_CARDS="dummy fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Comment 1 Stephan Hartmann 2018-03-01 13:10:02 UTC
FreeBSD requires to define _WITH_GETLINE before including stdio.h. Something like this should work:

#if defined(__FreeBSD__) && !defined(_WITH_GETLINE)
 #define _WITH_GETLINE
#include <stdio.h>
Comment 2 William Hubbs gentoo-dev 2018-03-01 18:01:44 UTC
The following commit should fix this and will be in OpenRC 0.35.1.
Comment 3 Stephan Hartmann 2018-03-02 12:24:33 UTC
The fix doesn't work. Problem is that somehow _POSIX_C_SOURCE=200112L and _XOPEN_SOURCE=600 added to gcc's command-line. However, both are not defined (and build succeeds) if I call gmake ... directly within openrc's build directory.
Comment 4 Stephan Hartmann 2018-03-02 13:11:34 UTC
The defines are set by mk/ via pkg-config --cflags ncurses. A workaround could be to remove the include of within src/rc/Makefile, since nothing inside rc uses ncurses.
Comment 5 William Hubbs gentoo-dev 2018-03-04 00:27:11 UTC
Created attachment 522228 [details, diff]

Please test with this patch and let me know if it resolves the issue.


Comment 6 William Hubbs gentoo-dev 2018-03-12 03:21:04 UTC
The best fix would be to fix the ncurses.pc file to not include the
unnecessary flags.

I could remove them in OpenRC's build system, but that is a hack;
ncurses should be fixed.

Which versions of ncurses add the inappropriate flags?
Comment 7 William Hubbs gentoo-dev 2018-03-12 23:33:38 UTC
According to my research, (the getline man page in FreeBSD), the way to
access the getline function is to add -D_WITH_GETLINE to the command
line. This is done.

Please provide a build log that shows any failures when trying to build
OpenRC 0.35.3.


Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-03-13 06:41:49 UTC
(In reply to William Hubbs from comment #7)
> According to my research, (the getline man page in FreeBSD), the way to
> access the getline function is to add -D_WITH_GETLINE to the command
> line. This is done.

Then I would suggest you continue your research past the first snippet because this is just a hack to work-around broken _POSIX_C_SOURCE:

     Applications that wish to use the getline() function described herein
     should either request a strict IEEE Std 1003.1-2008 (``POSIX.1'')
     environment by defining the macro _POSIX_C_SOURCE to the value 200809 or
     greater, or by defining the macro _WITH_GETLINE, prior to the inclusion
     of <stdio.h>.
Comment 9 William Hubbs gentoo-dev 2018-03-13 15:44:52 UTC
I did see that, and it seems to imply that I can define either macro.
Comment 10 William Hubbs gentoo-dev 2018-03-14 18:18:12 UTC
It looks like _BSD_SOURCE is probably a good way to go for this.
Otherwise I'll end up rewriting at least vsyslog and strsep.
Comment 11 William Hubbs gentoo-dev 2018-03-14 19:29:58 UTC
Please test with 0.35.4 and report back. It turned out that I need
_BSD_SOURCE because we use vsyslog and strsep which are not posix c.
Comment 12 William Hubbs gentoo-dev 2018-03-18 18:47:14 UTC
0.35.5 has been in the tree for several days now, so I need to know
whether it builds on FreeBSD.

Could someone test and let me know?


Comment 13 Stephan Hartmann 2018-03-28 11:35:14 UTC
(In reply to William Hubbs from comment #12)
> 0.35.5 has been in the tree for several days now, so I need to know
> whether it builds on FreeBSD.
> Could someone test and let me know?
> Thanks,
> William

Still doesn't work.
Comment 14 William Hubbs gentoo-dev 2018-05-07 22:13:59 UTC
Created attachment 530390 [details, diff]

Please test with this patch against 0.35.5 and let me know if it builds.


Comment 15 William Hubbs gentoo-dev 2018-05-08 22:48:36 UTC
I am adding base-system to this bug since the issue is in ncurses.
Comment 16 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-05-09 07:27:46 UTC
Well, the patch either fixes it or triggers another error before it:

x86_64-gentoo-freebsd11.1-gcc -fPIC -DPIC  -I../includes -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L  -O2 -pipe -march=native -std=c99 -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wnested-externs -Winline -Wwrite-strings -Wcast-align -Wcast-qual -Wpointer-arith -Wdeclaration-after-statement -Wsequence-point -Werror=implicit-function-declaration   -c librc.c -o librc.So
In file included from /usr/include/machine/pcb.h:7:0,
                 from /usr/include/sys/user.h:38,
                 from librc.h:49,
                 from librc.c:21:
/usr/include/machine/amd64_fbsd/pcb.h:79:2: error: unknown type name ‘u_int’
  u_int  pcb_flags;
In file included from /usr/include/sys/user.h:44:0,
                 from librc.h:49,
                 from librc.c:21:
/usr/include/sys/ucred.h:84:2: error: unknown type name ‘u_int’
Comment 17 William Hubbs gentoo-dev 2018-05-09 17:50:58 UTC
Created attachment 530642 [details, diff]

Ok, try this patch.
Let me know if it works.


Comment 18 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-05-09 17:58:47 UTC
Fails the same as previous.
Comment 19 William Hubbs gentoo-dev 2018-05-14 23:56:12 UTC
I was just advised on the #freebsd-ports channel that
OpenRC 0.35.5 and HEAD build successfully on
native FreeBSD version 11-stable a couple of months old.

So, does anyone have any suggestions?
Comment 20 Michał Dec 2018-06-16 22:16:57 UTC
This keeps happening with sys-apps/openrc-0.36
Comment 21 William Hubbs gentoo-dev 2018-06-18 18:44:34 UTC
As I stated above, I was advised that OpenRC builds fine on native

It seems like this might be because of a custom patch we carry which has
not been upstreamed in FreeBSD.


Comment 22 Patrice Clement gentoo-dev 2018-06-21 16:06:55 UTC
OK I've tried something silly which is to comment out the current src_compile() function and define another one which looks like this:

src_compile() {

Now, compilation works out fine. I think something is up in some of the args given to make/gcc throug emake. Could someone else confirm?
Comment 23 Patrice Clement gentoo-dev 2018-06-21 16:07:10 UTC
Comment 24 William Hubbs gentoo-dev 2018-06-21 21:47:40 UTC
Created attachment 536742 [details]

This is ncurses.pc from a native FreeBSD system.
Comment 25 William Hubbs gentoo-dev 2018-06-21 21:53:28 UTC
Created attachment 536744 [details]

This is the ncurses.pc from a Gentoo/FreeBSD system.
This is how upstream ncurses writes their *.pc files. However, this is
incorrect as shown in the discussion linked in the see also section of
this bug.

This is definitely a ncurses bug rather than an OpenRC bug.