Opened 5 years ago

Closed 5 years ago

#11199 closed defect (fixed)

dhcp: Fix compiler error

Reported by: thomas Owned by: thomas
Priority: normal Milestone: 8.4
Component: BOOK Version: SVN
Severity: normal Keywords:


(Reported by Clayton J. on blfs-dev)

Instructions in book leads to errors like

discover.c:646:4: error: 'strncpy' output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation]
    strncpy(tmp->name,, sizeof(tmp->name) - 1);

This is caused by a strange handling of set/unset CFLAGS. Doing an

export CFLAGS="-D...

makes it compile. Most likely it has been missed because we might had CFLAGS exported while testing. With this export of CFLAGS, our -D's are recognized but but -fno-strict-aliasing gets not set but it would be if CFLAGS are not spezified.

Remove the -Werror flag by doing a

sed -e "/STD_CWARNINGS=/ s/-Werror//" -i configure

This would make it compile too but the CFLAGS we set (without the export) will not be used. See summary of configure script.

I'd propose to solve it like this:

export CFLAGS="$CFLAGS -Wall -fno-strict-aliasing \
        -D_PATH_DHCLIENT_SCRIPT='\"/sbin/dhclient-script\"' \
        -D_PATH_DHCPD_CONF='\"/etc/dhcp/dhcpd.conf\"' \
./configure --prefix=/usr                                           \
            --sysconfdir=/etc/dhcp                                  \
            --localstatedir=/var                                    \
            --with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases       \
            --with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases     \
            --with-cli-lease-file=/var/lib/dhclient/dhclient.leases \

The summary of configure than looks like (note the CFLAGS line):

     ISC DHCP source configure results:

  Name:          DHCP
  Version:       4.4.1

C Compiler:      gcc

  DEFS:          -DHAVE_CONFIG_H
  CFLAGS:         -Wall -fno-strict-aliasing         -D_PATH_DHCLIENT_SCRIPT='"/sbin/dhclient-script"'         -D_PATH_DHCPD_CONF='"/etc/dhcp/dhcpd.conf"'         -D_PATH_DHCLIENT_CONF='"/etc/dhcp/dhclient.conf"'  -I$(top_srcdir)/includes -I/home/lfs/dhcp-4.4.1/bind/include

DHCP versions:   DHCPv4 and DHCPv6

  debug:         no
  failover:      yes
  execute:       yes
  binary-leases: no
  dhcpv6:        yes
  delayed-ack:   yes
  dhcpv4o6:      no
  relay-port:    no

  ATF unittests : no

Now you can type make to build ISC DHCP

Please add comments!

Change History (3)

comment:1 by Bruce Dubbs, 5 years ago

One thing to keep in mind is that we need to see if CFLAGS is already set and if it is, save it and restore it after the package has been installed,

comment:2 by thomas, 5 years ago

Owner: changed from blfs-book to thomas
Status: newassigned

comment:3 by thomas, 5 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r20561 by exporting modified CFLAGS in a subshell. The subshell saves CFLAGS if they are allready set in environment.

Note: See TracTickets for help on using tickets.