<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 complains of undefined _main symbol for x86_64 when compiling from stdin"
   href="http://llvm.org/bugs/show_bug.cgi?id=15403">15403</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang complains of undefined _main symbol for x86_64 when compiling from stdin
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jtolds@xnet5.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This works:

  echo "int main() {}" > test.cpp
  clang++ -stdlib=libc++ -std=c++0x -arch i386 -arch x86_64 -x c++ test.cpp -o
/dev/null

But this doesn't:

  echo "int main() {}" | clang++ -stdlib=libc++
-std=c++0x -arch i386 -arch x86_64 -x c++ - -o /dev/null

It fails with this message:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Running again with -v gives:

Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
 "/usr/bin/clang" -cc1 -triple i386-apple-macosx10.8.0 -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -main-file-name - -pic-level 2
-mdisable-fp-elim -masm-verbose -target-cpu yonah -target-linker-version 136 -v
-resource-dir /usr/bin/../lib/clang/4.2 -fmodule-cache-path
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/clang-module-cache
-stdlib=libc++ -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /Users/jt
-ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks
-fobjc-runtime=macosx-fragile-10.8.0 -fobjc-default-synthesize-properties
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--iarxmw.o -x c++ -
clang -cc1 version 4.2 based upon LLVM 3.2svn default target
x86_64-apple-darwin12.2.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/4.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -dynamic -arch i386 -macosx_version_min 10.8.0 -o
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--x57dHr.out
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--iarxmw.o -arch_multiple
-final_output /dev/null -lc++ -lSystem
/usr/bin/../lib/clang/4.2/lib/darwin/libclang_rt.eprintf.a
/usr/bin/../lib/clang/4.2/lib/darwin/libclang_rt.osx.a
 "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -main-file-name - -pic-level 2
-mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 136 -v -resource-dir /usr/bin/../lib/clang/4.2
-fmodule-cache-path
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/clang-module-cache
-stdlib=libc++ -std=c++0x -fdeprecated-macro -fdebug-compilation-dir /Users/jt
-ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks
-fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed
-fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--pIxdEO.o -x c++ -
clang -cc1 version 4.2 based upon LLVM 3.2svn default target
x86_64-apple-darwin12.2.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/c++/v1
 /usr/local/include
 /usr/bin/../lib/clang/4.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.8.0 -o
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--7tM9gO.out
/var/folders/qj/qqp5sv157yx96nj0rt_g96rw0000gn/T/--pIxdEO.o -arch_multiple
-final_output /dev/null -lc++ -lSystem
/usr/bin/../lib/clang/4.2/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)</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>