Bug 99476 - 'PATH_MAX' was not declared in this scope
Summary: 'PATH_MAX' was not declared in this scope
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2021-03-08 22:35 UTC by cqwrteur
Modified: 2024-02-21 05:12 UTC (History)
8 users (show)

See Also:
Host: x86_64-msys2-mingw-w64, windows 10
Target: x86_64-freebsd13
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
sanitizers do not find PATH_MAX and use linux headers (1.19 KB, text/plain)
2021-03-08 22:35 UTC, cqwrteur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cqwrteur 2021-03-08 22:35:42 UTC
Created attachment 50334 [details]
sanitizers do not find PATH_MAX and use linux headers

I try to cross compile gcc from windows to freebsd.
PATH_MAX does not exist.
Comment 1 cqwrteur 2022-01-16 23:31:47 UTC
../../../../../../../gcc/libsanitizer/asan/asan_linux.cpp: In function 'void __asan::AsanCheckIncompatibleRT()':
../../../../../../../gcc/libsanitizer/asan/asan_linux.cpp:200:21: error: 'PATH_MAX' was not declared in this scope
  200 |       char filename[PATH_MAX];
      |                     ^~~~~~~~
../../../../../../../gcc/libsanitizer/asan/asan_linux.cpp:201:35: error: 'filename' was not declared in this scope; did you mean 'rename'?
  201 |       MemoryMappedSegment segment(filename, sizeof(filename));
      |                                   ^~~~~~~~
      |                                   rename

The bug is still in the source
Comment 2 YunQiang Su 2023-05-18 03:46:04 UTC
Since commit
    59e4c98173a79fcaa2c33253261409f38856c384
You can add an configure option
    --includedir=/you/sysroot/include
to solve this problem.

/you/sysroot/include should contains a real workable limits.h.

The reason is due to that if gcc cannot find a limits.h,
it will use its ./gcc/glimits.h, which has no PATH_MAX defined.
Comment 3 Ilya Leoshkevich 2024-01-08 09:50:42 UTC
I had a similar issue when compiling GCC targeting i686-linux on x86_64 debian, and --includedir= helped, thanks! I had to do the following:

../configure --target=i686-linux-gnu --disable-bootstrap --prefix=/usr --includedir=/usr/i686-linux-gnu/include
Comment 4 Andrew Pinski 2024-02-21 05:12:19 UTC
This has to do with the way you are doing the cross compiling. Either use a sysroot (with --with-sysroot=DIR) or use includedir as directed below.