Compile-rt throw error undeclared identifier 'O_CLOEXEC'

Hello All,

I build LLVM source code version 3.2 from SVN repository. After I build source code of LLVM include “compiler-rt”(Compiler-rt at revision 158057.
) and “clang” are represent an error as below.

make[5]: Entering directory `/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt’
COMPILE: clang_linux/asan-x86_64/x86_64: /san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:47:36: error: use of
undeclared identifier ‘O_CLOEXEC’
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660); ^
1 error generated.

Who have any idea with error these?

Best Regards,
Chatsiri Rattana.

Hi, Chatsiri!

From: Chatsiri Ratana <insiderboy@gmail.com>
Date: Wed, Jun 6, 2012 at 2:15 PM
Subject: [LLVMdev] Compile-rt throw error undeclared identifier ‘O_CLOEXEC’
To: llvmdev@cs.uiuc.edu

Hello All,

I build LLVM source code version 3.2 from SVN repository. After I build source code of LLVM include “compiler-rt”(Compiler-rt at revision 158057.
) and “clang” are represent an error as below.

make[5]: Entering directory `/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt’
COMPILE: clang_linux/asan-x86_64/x86_64: /san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:47:36: error: use of
undeclared identifier ‘O_CLOEXEC’
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660); ^
1 error generated.

Who have any idea with error these?

The code in sanitizer_linux.cc calls libc function “open” and passes O_CLOEXEC as a flag to it. “man open” says:
“O_CLOEXEC (Since Linux 2.6.23)”
is it possible that your Linux is older that a given version?

Hi, Chatsiri!

From: Chatsiri Ratana <insiderboy@gmail.com>
Date: Wed, Jun 6, 2012 at 2:15 PM
Subject: [LLVMdev] Compile-rt throw error undeclared identifier ‘O_CLOEXEC’
To: llvmdev@cs.uiuc.edu

Hello All,

I build LLVM source code version 3.2 from SVN repository. After I build source code of LLVM include “compiler-rt”(Compiler-rt at revision 158057.
) and “clang” are represent an error as below.

make[5]: Entering directory `/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt’
COMPILE: clang_linux/asan-x86_64/x86_64: /san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:47:36: error: use of
undeclared identifier ‘O_CLOEXEC’
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660); ^
1 error generated.

Who have any idea with error these?

The code in sanitizer_linux.cc calls libc function “open” and passes O_CLOEXEC as a flag to it. “man open” says:
“O_CLOEXEC (Since Linux 2.6.23)”
is it possible that your Linux is older that a given version?

Hi!,

It’s present version after check with “uname -r” command line. Kernel version 2.6.18-194.17.4.el5. I cannot upgrade version of kernel because another programs depend on current kernel version. How can i work around this situation?

Best Regards,
Chatsiri Rattana

Hi, Chatsiri!

From: Chatsiri Ratana <insiderboy@gmail.com>
Date: Wed, Jun 6, 2012 at 2:15 PM
Subject: [LLVMdev] Compile-rt throw error undeclared identifier ‘O_CLOEXEC’
To: llvmdev@cs.uiuc.edu

Hello All,

I build LLVM source code version 3.2 from SVN repository. After I build source code of LLVM include “compiler-rt”(Compiler-rt at revision 158057.
) and “clang” are represent an error as below.

make[5]: Entering directory `/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt’
COMPILE: clang_linux/asan-x86_64/x86_64: /san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
/san01/home/chatsiri/workspacecpp/llvm-svn/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:47:36: error: use of
undeclared identifier ‘O_CLOEXEC’
write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660); ^
1 error generated.

Who have any idea with error these?

The code in sanitizer_linux.cc calls libc function “open” and passes O_CLOEXEC as a flag to it. “man open” says:
“O_CLOEXEC (Since Linux 2.6.23)”
is it possible that your Linux is older that a given version?

Hi!,

It’s present version after check with “uname -r” command line. Kernel version 2.6.18-194.17.4.el5. I cannot upgrade version of kernel because another programs depend on current kernel version. How can i work around this situation?

I guess you can simply replace
O_WRONLY | O_CREAT | O_CLOEXEC
with
O_WRONLY | O_CREAT

If that helps, we will probably need to put this under some sort of ifdef…

–kcc