Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error building implicit function and incompatible integer to pointer conversion #26087

Closed
karasjoh000 opened this issue Nov 17, 2023 · 7 comments · Fixed by #26124
Closed

error building implicit function and incompatible integer to pointer conversion #26087

karasjoh000 opened this issue Nov 17, 2023 · 7 comments · Fixed by #26124
Labels
bug issues reporting wrong behavior build building and installing Neovim using the provided scripts

Comments

@karasjoh000
Copy link

karasjoh000 commented Nov 17, 2023

Problem

# CCACHE_DISABLE=true make CMAKE_BUILD_TYPE=Release \
#	CMAKE_INSTALL_PREFIX=$HOME/.neovim.install \
#	CMAKE_EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icpx -DCMAKE_C_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icx' \
#       DEPS_CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icpx -DCMAKE_C_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icx"

[ 77%] Building C object src/nvim/CMakeFiles/nvim.dir/os/pty_process_unix.c.o
/home/jkarasev/neovim/src/nvim/os/pty_process_unix.c:232:10: error: call to undeclared function 'ptsname'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  232 |   return ptsname(ptyproc->tty_fd);
      |          ^
/home/jkarasev/neovim/src/nvim/os/pty_process_unix.c:232:10: note: did you mean 'ttyname'?
/usr/include/unistd.h:799:14: note: 'ttyname' declared here
  799 | extern char *ttyname (int __fd) __THROW;
      |              ^
/home/jkarasev/neovim/src/nvim/os/pty_process_unix.c:232:10: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'const char *' [-Wint-conversion]
  232 |   return ptsname(ptyproc->tty_fd);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
make[3]: *** [src/nvim/CMakeFiles/nvim.dir/build.make:3454: src/nvim/CMakeFiles/nvim.dir/os/pty_process_unix.c.o] Error 1
make[3]: Leaving directory '/home/jkarasev/neovim/build'
make[2]: *** [CMakeFiles/Makefile2:532: src/nvim/CMakeFiles/nvim.dir/all] Error 2
make[2]: Leaving directory '/home/jkarasev/neovim/build'
make[1]: *** [Makefile:156: all] Error 2
make[1]: Leaving directory '/home/jkarasev/neovim/build'
make: *** [Makefile:84: nvim] Error 2

Steps to reproduce

CCACHE_DISABLE=true make CMAKE_BUILD_TYPE=Release \
	CMAKE_INSTALL_PREFIX=$HOME/.neovim.install \
	CMAKE_EXTRA_FLAGS='-DCMAKE_CXX_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icpx -DCMAKE_C_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icx' \
	DEPS_CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icpx -DCMAKE_C_COMPILER=/home/jkarasev/intel/oneapi/compiler/2024.0/bin/icx"

Expected behavior

It should compile without error

Neovim version (nvim -v)

fe869a8

Vim (not Nvim) behaves the same?

Did not try this.

Operating system/version

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Terminal name/version

ubuntu wsl

$TERM environment variable

tmux-256color

Installation

build from repo

@karasjoh000 karasjoh000 added the bug issues reporting wrong behavior label Nov 17, 2023
@zeertzjq
Copy link
Member

Please provide Ubuntu version. (E.g. from the output of lsb_release -a)

@zeertzjq zeertzjq added the needs:response waiting for reply from the author label Nov 17, 2023
@karasjoh000
Copy link
Author

@zeertzjq added ubuntu version.

@github-actions github-actions bot removed the needs:response waiting for reply from the author label Nov 17, 2023
@zeertzjq zeertzjq added the build building and installing Neovim using the provided scripts label Nov 17, 2023
@karasjoh000
Copy link
Author

note a temporary fix seems to be adding this into the CMakeLists.txt:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration -Wno-int-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-function-declaration -Wno-int-conversion")

but not permanent fix. It can be an Intel compiler issue, because it seems like the implicit function in question did have included header. idk. Maybe some macro logic for headers.

@e-kwsm
Copy link
Contributor

e-kwsm commented Nov 20, 2023

I can reproduce the issue with icx 2023.1.0 on Debian 12.2 (glibc 2.36).

The simplest solution is to add -D_GNU_SOURCE, which satisifies the followings:

  • -D_XOPEN_SOURCE=500 for ptsname500 is the minimum, and -D_GNU_SOURCE sets it to 700
  • -D_POSIX_C_SOURCE=200809L for strnlen
  • -D_DEFAULT_SOURCE for htobe64

The macros and their required values depend on the glibc version, as specified in the man’s.
See also feature_test_macros(7).

Anyway, I believe this is an icx–glibc problem.

@e-kwsm
Copy link
Contributor

e-kwsm commented Nov 20, 2023

if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
target_link_libraries(nvim PRIVATE -Wl,--no-undefined -lsocket)
# workaround for clang-11 on macOS, supported on later versions:
elseif(NOT APPLE)
target_link_libraries(nvim PRIVATE -Wl,--no-undefined)
endif()
# For O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags on older systems
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
# For ptsname(). #6743
target_compile_definitions(main_lib INTERFACE _GNU_SOURCE)
endif()

#4042, #4094, #6743

dundargoc added a commit to dundargoc/neovim that referenced this issue Nov 20, 2023
Also add _GNU_SOURCE compiler definition for all non MSVC compilers.

Closes neovim#26087.
@dundargoc
Copy link
Member

@e-kwsm @karasjoh000 does #26124 solve this problem?

@dundargoc dundargoc added the needs:response waiting for reply from the author label Nov 20, 2023
@e-kwsm
Copy link
Contributor

e-kwsm commented Nov 21, 2023

Yes, it fixes the issue.

@zeertzjq zeertzjq removed the needs:response waiting for reply from the author label Nov 21, 2023
dundargoc added a commit to dundargoc/neovim that referenced this issue Nov 21, 2023
Also add _GNU_SOURCE compiler definition for all non MSVC compilers.

Closes neovim#26087.
dundargoc added a commit that referenced this issue Nov 21, 2023
Also add _GNU_SOURCE compiler definition for all non MSVC compilers.

Closes #26087.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior build building and installing Neovim using the provided scripts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants