<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-cl doesn't respect -Xclang -fno-builtin"
href="https://bugs.llvm.org/show_bug.cgi?id=36427">36427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl doesn't respect -Xclang -fno-builtin
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wjk011@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19891" name="attach_19891" title="Repro case for bug">attachment 19891</a> <a href="attachment.cgi?id=19891&action=edit" title="Repro case for bug">[details]</a></span>
Repro case for bug
Try to compile the file rot.c (attached to this bug). It redefines several
built-in functions, so by default, Clang will emit errors stating as such.
However, these functions must be compiled as defined in this file to avoid
linker errors later. (This file comes from ReactOS,
<<a href="https://github.com/reactos/reactos">https://github.com/reactos/reactos</a>>, which must maintain compatibility with
many different compilers other than just clang.) Therefore, I use the
-fno-builtin flag to suppress builtin functions, as well as this error.
If I execute the following command, clang compiles the file correctly:
clang -target i386-pc-mingw32 -fno-builtin -c rot.c
If I execute the equivalent clang-cl invocation however, -fno-builtin appears
to be ignored, and the redefinition-of-builtin error appears:
clang-cl -Xclang -fno-builtin /c rot.c
However, adding the -v flag to clang-cl (the full output of which is included
below) reveals that -fno-builtin is correctly passed to clang -cc1. As I
understand it, the behavior should be identical whether I pass -fno-builtin to
regular clang, or by using the -Xclang flag to clang-cl.
If there is anything else you would need to help fix this, please just let me
know. Thanks!
=== output of clang-cl -v ===
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
"/usr/local/Cellar/llvm/5.0.1/bin/clang-5.0" -cc1 -triple
x86_64-pc-windows-msvc18.0.0 -emit-obj -mrelax-all
-mincremental-linker-compatible -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name rot.c -mrelocation-model pic -pic-level 2
-mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -D_MT
-flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames
-stack-protector 2 -fms-volatile -fdiagnostics-format msvc
-target-linker-version 305 -momit-leaf-frame-pointer -v -dwarf-column-info
-debugger-tuning=gdb -coverage-notes-file /Users/wjk/rot.gcno -resource-dir
/usr/local/Cellar/llvm/5.0.1/lib/clang/5.0.1 -internal-isystem
/usr/local/Cellar/llvm/5.0.1/lib/clang/5.0.1/include -fdebug-compilation-dir
/Users/wjk -ferror-limit 19 -fmessage-length 0 -fms-extensions
-fms-compatibility -fms-compatibility-version=18 -fno-threadsafe-statics
-fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option
-fno-builtin -o rot.obj -x c /tmp/rot.c
clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target
x86_64-apple-darwin17.4.0
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/llvm/5.0.1/lib/clang/5.0.1/include
End of search list.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>