Skip to content

implicit declaration of function is invalid in C99 - MacOS x86 #1199

@meow464

Description

@meow464

Solution

It was entirely my fault. I was running the commands from the wrong directory, this flang instead of the fork with macos support.

Following the build instructions on step 3 (flang/runtime/libpgmath) I get an error.

Environment

macOS Big Sur x86_64
Apple clang version 12.0.5 (clang-1205.0.22.11)
clang 10.0 when using classic-flang-llvm-project

INSTALL_PREFIX=/usr/local

CMAKE_OPTIONS="-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DLLVM_CONFIG=$INSTALL_PREFIX/bin/llvm-config \
-DCMAKE_CXX_COMPILER=$INSTALL_PREFIX/bin/clang++ -DCMAKE_C_COMPILER=$INSTALL_PREFIX/bin/clang \
-DCMAKE_Fortran_COMPILER=$INSTALL_PREFIX/bin/flang -DCMAKE_Fortran_COMPILER_ID=Flang \
-DLLVM_TARGETS_TO_BUILD=X86"

What I tried

cmake $CMAKE_OPTIONS .. # here it uses classic-flang-llvm-project under /usr/local
cmake $CMAKE_OPTIONS -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ..
cmake $CMAKE_OPTIONS -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ ..

Reverting this commit

The error

But after make I get:

[ 30%] Building C object lib/common/CMakeFiles/common.dir/fpcvt.c.o
/Users/tuco/Projects/flang/flang/runtime/libpgmath/lib/common/fpcvt.c:421:5: error: implicit declaration of function '__io_set_errno' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    __io_set_errno(ERANGE);
    ^
/Users/tuco/Projects/flang/flang/runtime/libpgmath/lib/common/fpcvt.c:427:5: error: implicit declaration of function '__io_set_errno' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    __io_set_errno(ERANGE);
    ^
/Users/tuco/Projects/flang/flang/runtime/libpgmath/lib/common/fpcvt.c:432:7: error: implicit declaration of function '__io_set_errno' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      __io_set_errno(ERANGE);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions