Skip to content

Commit 6148cca

Browse files
committed
[compiler-rt] Fix build of Sanitizer-Test_Nolibc after D80648
Running ninja check-sanitizer fails for after that patch (commit 058f5f6) with the following error: libRTSanitizerCommon.test.nolibc.x86_64.a(sanitizer_posix.cpp.o): In function `__sanitizer::GetNamedMappingFd(char const*, unsigned long, int*)': ..../llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp:358: undefined reference to `fcntl' clang-12: error: linker command failed with exit code 1 (use -v to see invocation) This patch works around the problem by only calling fcntl if O_CLOEXEC is not defined. Reviewed By: plopresti Differential Revision: https://reviews.llvm.org/D85114
1 parent 3b3cdcc commit 6148cca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ int GetNamedMappingFd(const char *name, uptr size, int *flags) {
354354
int fd = ReserveStandardFds(
355355
internal_open(shmname, O_RDWR | O_CREAT | O_TRUNC | o_cloexec, S_IRWXU));
356356
CHECK_GE(fd, 0);
357-
if (!o_cloexec) {
358-
int res = fcntl(fd, F_SETFD, FD_CLOEXEC);
359-
CHECK_EQ(0, res);
360-
}
361357
int res = internal_ftruncate(fd, size);
358+
#if !defined(O_CLOEXEC)
359+
res = fcntl(fd, F_SETFD, FD_CLOEXEC);
360+
CHECK_EQ(0, res);
361+
#endif
362362
CHECK_EQ(0, res);
363363
res = internal_unlink(shmname);
364364
CHECK_EQ(0, res);

0 commit comments

Comments
 (0)