bugGNU tar - Bugs: bug #59755, error: implicit declaration of...

 
 

bug #59755: error: implicit declaration of ioctl: sys/ioctl.h not included on macOS (patch attached)

Submitter:  Alexei Colin <alexeicolin>
Submitted:  Wed 23 Dec 2020 04:39:08 AM UTC
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Wed 23 Dec 2020 04:39:08 AM UTC, original submission:  

On macOS 11 Big Sur, build fails for 1.32 and master 01dd89c121713beef676837d6e6accb98760ddc4 (Jul 13, 2020) because sys/ioctl.h does not end up included:

    gcc -DHAVE_CONFIG_H -I. -I..  -I../gnu -I../ -I../gnu -I../lib -I../lib -I/usr/local/include   -g -O2 -MT compare.o -MD -MP -MF .deps/compare.Tpo -c -o compare.o compare.c

    compare.c:566:3: error: implicit declaration of function 'ioctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      ioctl (archive, FDFLUSH);
      ^

The logic in [paxutils]/lib/system-ioctl.h appears to include sys/ioctl.h only if sys/mtio.h is found. On Linux (tested on CentOS 7 and Arch) both headers exist and are detected, but, at least on macOS 11 Big Sur, sys/ioctl.h exists while sys/mtio.h does not:

    find /Library/Developer/ -path '*/sys/mtio.h'
    find /Library/Developer/ -path '*/sys/ioctl.h'
    /Library/Developer//CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/sys/ioctl.h

Should the inclusion checks for these two headers be independent instead? I attached a patch that adds a check for sys/ioctl.h and includes it if found, regardless of the status of sys/mtio.h.

Sidenote: I'm also including an optional patch to checkpoint.c to use system-ioctl.h instead of sys/ioctl.h directly. It's not required to fix the build on macOS, just a proposal.

Attaching patch against 1.32 release (needs autoreconf), and against master. Tested patched on macOS 11 Big Sur, CentOS7, Arch Linux, and Gentoo-Prefix-on-macOS (on latter two tested only patched release 1.32, since master doesn't build with gcc 10, due to Bug #58853). Attaching build logs with and without patch.

Compiler and header info:

    ./configure
    ...
    checking for gcc... gcc
    ...
    checking for sys/gentape.h... no
    checking for sys/inet.h... no
    checking for sys/io/trioctl.h... no
    checking for sys/mtio.h... no
    checking for sys/time.h... yes
    checking for sys/tprintf.h... yes
    checking for sys/tape.h... no

Clang is aliased to gcc on macOS:

    gcc --version
    Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    Apple clang version 12.0.0 (clang-1200.0.32.28)
    Target: x86_64-apple-darwin20.2.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Alexei Colin <alexeicolin>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50554:  tar-1.32-check-sys-ioctl-header-configure.patch added by alexeicolin (1KiB - application/octet-stream - A variant of the patch on top of 1.32 release that patches automake generated files, to avoid autoreconf step.)
file #50550:  tar-vcs-check-sys-ioctl-header.patch added by alexeicolin (1KiB - application/octet-stream - Patches with fix against latest release and against master, and full build logs.)
file #50551:  tar-1.32-check-sys-ioctl-header.patch added by alexeicolin (1KiB - application/octet-stream - Patches with fix against latest release and against master, and full build logs.)
file #50552:  build-error.log added by alexeicolin (164KiB - application/octet-stream - Patches with fix against latest release and against master, and full build logs.)
file #50553:  build-patched.log added by alexeicolin (190KiB - application/octet-stream - Patches with fix against latest release and against master, and full build logs.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by alexeicolin (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-12-23 alexeicolin Attached File- Added tar-1.32-check-sys-ioctl-header-configure.patch, #50554
    2020-12-23 alexeicolin Attached File- Added tar-vcs-check-sys-ioctl-header.patch, #50550
        Attached File- Added tar-1.32-check-sys-ioctl-header.patch, #50551
        Attached File- Added build-error.log, #50552
        Attached File- Added build-patched.log, #50553

    Back to the top

    Powered by Savane 3.11