Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[flang][CMake] CYGWIN requires _GNU_SOURCE to be defined. #66747

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

carlo-bramini
Copy link
Contributor

Compiling flang on CYGWIN prints this error message on the console:

llvm-project/flang/include/flang/Parser/char-block.h: In member function ‘std::string Fortran::parser::CharBlock::NULTerminatedToString() const’: llvm-project/flang/include/flang/Parser/char-block.h:106:26: error: ‘strnlen’ was not declared in this scope; did you mean ‘strlen’?
  106 |         /*not in std::*/ strnlen(interval_.start(), interval_.size())};
      |                          ^~~~~~~
      |                          strlen

strnlen() exists into NEWLIB, but it requires to define _GNU_SOURCE macro somewhere for having its prototype available.
This patch adds this definition, by using the same code written here:

add_definitions(-D_GNU_SOURCE=1)

Compiling flang on CYGWIN prints this error message on the console:

llvm-project/flang/include/flang/Parser/char-block.h: In member function ‘std::string Fortran::parser::CharBlock::NULTerminatedToString() const’:
llvm-project/flang/include/flang/Parser/char-block.h:106:26: error: ‘strnlen’ was not declared in this scope; did you mean ‘strlen’?
  106 |         /*not in std::*/ strnlen(interval_.start(), interval_.size())};
      |                          ^~~~~~~
      |                          strlen

strnlen() exists into NEWLIB, but it requires to define _GNU_SOURCE macro somewhere for having its prototype available.
This patch adds this definition, by using the same code written here:

https://github.com/llvm/llvm-project/blob/53602e6193d98b1e814b76a27e99ef7e18c9769c/third-party/benchmark/CMakeLists.txt#L230
@carlo-bramini carlo-bramini changed the title [flang] CYGWIN required _GNU_SOURCE to be defined. [flang] CYGWIN requires _GNU_SOURCE to be defined. Sep 19, 2023
@llvmbot llvmbot added the flang Flang issues not falling into any other category label Sep 19, 2023
@carlo-bramini carlo-bramini changed the title [flang] CYGWIN requires _GNU_SOURCE to be defined. [flang][CMake] CYGWIN requires _GNU_SOURCE to be defined. Sep 20, 2023
@mati865
Copy link
Contributor

mati865 commented May 13, 2025

Fixed by #138329 and #138587

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.