Building Clang with Visual Studio 2010 Express

Hi,

I some questions/observations on building Clang v 3.0 (and LLVM 3.0),
unmodified website sources with Visual Studio 2010 Express.

1. I followed the instructions on:
http://clang.llvm.org/get_started.html , installed the required
software (cmake, python, gnuwin32), updated the PATH environmental
variable and launched:
C:\Users\XXX\prj\llvm-3.0\build>cmake -G "Visual Studio 10"
-DCMAKE_INSTALL_PREFIX=C:\Users\XXX\prj\llvm-3.0\llvm-3.0.install
..\llvm-3.0.src
(the result is reported at the end of the e-mail in case it helps).
LVVM.sln is correctly generated.
Opening it with Visual Studio 2010 Express results in a problem: some
projects (Clang executables, Clang libraries, ...) are unavailable as
"Solution Folders are unsupported in this version."
I can still compile clang and ALL_BUILD fine, so it may be worth
adding a notice on the getting started webpage.

2. Building clang and ALL_BUILD did not result in anything being
installed in the directory specified above via DCMAKE_INSTALL_PREFIX.
Is this the expected behaviour?

3. I cannot run the regression test by building clang-test as it
cannot find bash.exe. However bash.exe seems not to be included in
GnuWin32. Should I install it separately? If so a note could be added
to the getting started page.

4. clang.exe cannot find my visual studio headers (I thought this
would happen by default when building Clang as above): trying to
compile a C file which has
#include <math.h>
gives an error (math.h: file not found).
Did I make some mistakes or should I add the Visual Studio headers by
hand via -I ?

Thank you again for all the help.

PS the reason I am compiling Clang with Visual Studio as well is
because the visual debugger helps me a lot with understanding the
working of the code.

++++++ output of point 1 ++++++++

C:\Users\XXX\prj\llvm-3.0\build>cmake -G "Visual Studio 10"
-DCMAKE_INSTALL_PREFI
X=C:\Users\XXX\prj\llvm-3.0\llvm-3.0.install ..\llvm-3.0.src
-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10
-- Check for working CXX compiler using: Visual Studio 10 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for argz.h
-- Looking for argz.h - not found
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for dirent.h
-- Looking for dirent.h - not found
-- Looking for dl.h
-- Looking for dl.h - not found
-- Looking for dld.h
-- Looking for dld.h - not found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - not found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for execinfo.h
-- Looking for execinfo.h - not found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - not found
-- Looking for limits.h
-- Looking for limits.h - found
-- Looking for link.h
-- Looking for link.h - not found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for malloc/malloc.h
-- Looking for malloc/malloc.h - not found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for ndir.h
-- Looking for ndir.h - not found
-- Looking for setjmp.h
-- Looking for setjmp.h - found
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for sys/dir.h
-- Looking for sys/dir.h - not found
-- Looking for sys/dl.h
-- Looking for sys/dl.h - not found
-- Looking for sys/ioctl.h
-- Looking for sys/ioctl.h - not found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - not found
-- Looking for sys/ndir.h
-- Looking for sys/ndir.h - not found
-- Looking for sys/param.h
-- Looking for sys/param.h - not found
-- Looking for sys/resource.h
-- Looking for sys/resource.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/uio.h
-- Looking for sys/uio.h - not found
-- Looking for sys/wait.h
-- Looking for sys/wait.h - not found
-- Looking for termios.h
-- Looking for termios.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for utime.h
-- Looking for utime.h - not found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for windows.h
-- Looking for windows.h - found
-- Looking for fenv.h
-- Looking for fenv.h - not found
-- Looking for mach/mach.h
-- Looking for mach/mach.h - not found
-- Looking for mach-o/dyld.h
-- Looking for mach-o/dyld.h - not found
-- Looking for getpagesize
-- Looking for getpagesize - not found.
-- Looking for getrusage
-- Looking for getrusage - not found.
-- Looking for setrlimit
-- Looking for setrlimit - not found.
-- Looking for isatty
-- Looking for isatty - found
-- Looking for index
-- Looking for index - not found.
-- Looking for isinf
-- Looking for isinf - not found.
-- Looking for isinf
-- Looking for isinf - not found.
-- Looking for finite
-- Looking for finite - not found.
-- Looking for isnan
-- Looking for isnan - not found.
-- Looking for isnan
-- Looking for isnan - not found.
-- Looking for ceilf
-- Looking for ceilf - found
-- Looking for floorf
-- Looking for floorf - found
-- Looking for fmodf
-- Looking for fmodf - found
-- Looking for longjmp
-- Looking for longjmp - found
-- Looking for setjmp
-- Looking for setjmp - found
-- Looking for siglongjmp
-- Looking for siglongjmp - not found.
-- Looking for sigsetjmp
-- Looking for sigsetjmp - not found.
-- Looking for nearbyintf
-- Looking for nearbyintf - not found.
-- Looking for mallinfo
-- Looking for mallinfo - not found.
-- Looking for malloc_zone_statistics
-- Looking for malloc_zone_statistics - not found.
-- Looking for mkdtemp
-- Looking for mkdtemp - not found.
-- Looking for mkstemp
-- Looking for mkstemp - not found.
-- Looking for mktemp
-- Looking for mktemp - not found.
-- Looking for closedir
-- Looking for closedir - not found.
-- Looking for opendir
-- Looking for opendir - not found.
-- Looking for readdir
-- Looking for readdir - not found.
-- Looking for getcwd
-- Looking for getcwd - not found.
-- Looking for gettimeofday
-- Looking for gettimeofday - not found.
-- Looking for getrlimit
-- Looking for getrlimit - not found.
-- Looking for rindex
-- Looking for rindex - not found.
-- Looking for strchr
-- Looking for strchr - found
-- Looking for strcmp
-- Looking for strcmp - found
-- Looking for strdup
-- Looking for strdup - found
-- Looking for strrchr
-- Looking for strrchr - found
-- Looking for sbrk
-- Looking for sbrk - not found.
-- Looking for srand48
-- Looking for srand48 - not found.
-- Looking for strtoll
-- Looking for strtoll - not found.
-- Looking for strtoq
-- Looking for strtoq - not found.
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strerror_r
-- Looking for strerror_r - not found.
-- Looking for strerror_s
-- Looking for strerror_s - found
-- Looking for memcpy
-- Looking for memcpy - found
-- Looking for memmove
-- Looking for memmove - found
-- Looking for setenv
-- Looking for setenv - not found.
-- Looking for _chsize_s
-- Looking for _chsize_s - found
-- Looking for _alloca
-- Looking for _alloca - not found
-- Looking for __alloca
-- Looking for __alloca - not found
-- Looking for __chkstk
-- Looking for __chkstk - not found
-- Looking for ___chkstk
-- Looking for ___chkstk - not found
-- Looking for __ashldi3
-- Looking for __ashldi3 - not found
-- Looking for __ashrdi3
-- Looking for __ashrdi3 - not found
-- Looking for __divdi3
-- Looking for __divdi3 - not found
-- Looking for __fixdfdi
-- Looking for __fixdfdi - not found
-- Looking for __fixsfdi
-- Looking for __fixsfdi - not found
-- Looking for __floatdidf
-- Looking for __floatdidf - not found
-- Looking for __lshrdi3
-- Looking for __lshrdi3 - not found
-- Looking for __moddi3
-- Looking for __moddi3 - not found
-- Looking for __udivdi3
-- Looking for __udivdi3 - not found
-- Looking for __umoddi3
-- Looking for __umoddi3 - not found
-- Looking for __main
-- Looking for __main - not found
-- Looking for __cmpdi2
-- Looking for __cmpdi2 - not found
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - not found.
-- Performing Test HAVE_INT64_T
-- Performing Test HAVE_INT64_T - Success
-- Performing Test HAVE_UINT64_T
-- Performing Test HAVE_UINT64_T - Success
-- Performing Test HAVE_U_INT64_T
-- Performing Test HAVE_U_INT64_T - Failed
-- Performing Test HAVE_ERROR_T
-- Performing Test HAVE_ERROR_T - Failed
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG
-- Performing Test SUPPORTS_NO_VARIADIC_MACROS_FLAG - Failed
-- Target triple: i686-pc-win32
-- Native target architecture is X86
-- Performing Test HAVE_ELMCB_PCSTR
-- Performing Test HAVE_ELMCB_PCSTR - Success
-- Threads enabled.
-- Using Debug VC++ CRT: MDd
-- Using Release VC++ CRT: MD
-- Using MinSizeRel VC++ CRT: MD
-- Using RelWithDebInfo VC++ CRT: MD
-- Loadable modules not supported on this platform.
LLVMHello ignored.
-- Targeting X86
-- Loadable modules not supported on this platform.
BugpointPasses ignored.
-- Clang version: 3.0
-- Could NOT find Subversion (missing: Subversion_SVN_EXECUTABLE)
-- Found PythonInterp: C:/Users/XXX/progs/Python27/python.exe (found
version "2.7
.3")
-- Loadable modules not supported on this platform.
profile_rt-shared ignored.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/XXX/prj/llvm-3.0/build

C:\Users\XXX\prj\llvm-3.0\build>ls
ALL_BUILD.vcxproj examples runtime
ALL_BUILD.vcxproj.filters include share
bin INSTALL.vcxproj test
cmake INSTALL.vcxproj.filters tools
cmake_install.cmake lib unittests
CMakeCache.txt LLVM.sln utils
CMakeFiles PACKAGE.vcxproj ZERO_CHECK.vcxproj
CPackConfig.cmake PACKAGE.vcxproj.filters ZERO_CHECK.vcxproj.filters
CPackSourceConfig.cmake projects

C:\Users\XXX\prj\llvm-3.0\build>LLVM.sln

Just to add some more info on point 4 below. Consider the following
test_clang.c:

#include <stdio.h>
int main(int argc, char **argv) {
  printf("hello world\n");
}

then:
- clang.exe -c test_clang.c
=> works, produces test_clang.o

- clang.exe test_clang.c
=> C:/Users/XXX/progs/gnuwin32/bin/link.exe: invalid option -- o
Try `C:/Users/XXX/progs/gnuwin32/bin/link.exe --help' for more information.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(the gnuwing32/bin directory is the last one appended to PATH, as
suggested in the gnuwin32 installer)

- clang.exe -cc1 test_clang.c
=> fatal error: stdlib.h not found
(including Visual Studio headers manually results in a lot of error,
previous messages on the mlist suggests that's expected. But then what
headers is clang without the -cc1 option using?)

What am I doing wrong? :slight_smile:

Thanks again.

Hi,

I some questions/observations on building Clang v 3.0 (and LLVM 3.0),
unmodified website sources with Visual Studio 2010 Express.

1. I followed the instructions on:
http://clang.llvm.org/get_started.html , installed the required
software (cmake, python, gnuwin32), updated the PATH environmental
variable and launched:
C:\Users\XXX\prj\llvm-3.0\build>cmake -G "Visual Studio 10"
-DCMAKE_INSTALL_PREFIX=C:\Users\XXX\prj\llvm-3.0\llvm-3.0.install
..\llvm-3.0.src
(the result is reported at the end of the e-mail in case it helps).
LVVM.sln is correctly generated.
Opening it with Visual Studio 2010 Express results in a problem: some
projects (Clang executables, Clang libraries, ...) are unavailable as
"Solution Folders are unsupported in this version."
I can still compile clang and ALL_BUILD fine, so it may be worth
adding a notice on the getting started webpage.

By the way, you can now switch off using solution folders in cmake
with -DLLVM_USE_FOLDERS=OFF

Cheers,
/Manuel

I just downloaded Clang 3.1 and it seems that this option is gone, is an alternative available to avoid the solution folders?

Thank you

Cheers

If I’m not mistaken, the patch landed after 3.1 was cut. You can simply patch this in yourself:
— llvm/trunk/CMakeLists.txt 2012/05/07 19:38:40 156319
+++ llvm/trunk/CMakeLists.txt 2012/05/09 15:10:54 156472
@@ -15,7 +15,10 @@

set(PACKAGE_VERSION “${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}svn”)

-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+option(LLVM_USE_FOLDERS “Enable solution folders in Visual Studio. Disable for Express versions.” ON)
+if ( LLVM_USE_FOLDERS )

  • set_property(GLOBAL PROPERTY USE_FOLDERS ON)
    +endif()

include(VersionFromVCS)

Cheers,
/Manuel

Just to add some more info on point 4 below. Consider the following
test_clang.c:

#include <stdio.h>
int main(int argc, char **argv) {
printf("hello world\n");
}

then:
- clang.exe -c test_clang.c
=> works, produces test_clang.o

- clang.exe test_clang.c
=> C:/Users/XXX/progs/gnuwin32/bin/link.exe: invalid option -- o
Try `C:/Users/XXX/progs/gnuwin32/bin/link.exe --help' for more information.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(the gnuwing32/bin directory is the last one appended to PATH, as
suggested in the gnuwin32 installer)

- clang.exe -cc1 test_clang.c
=> fatal error: stdlib.h not found
(including Visual Studio headers manually results in a lot of error,
previous messages on the mlist suggests that's expected. But then what
headers is clang without the -cc1 option using?)

What am I doing wrong? :slight_smile:

Thanks again.

You need to run clang from a term that has the correct environment
variables set for your VS install. The problem is that it's picking up
gnuwin32 link.exe instead of MSVC link.exe. You can either open
cmd.exe and manually run: \Program Files (x86)\Microsoft Visual Studio
10.0\VC\bin\vcvars32.bat, or you can open the "Visual Studio Command
Prompt (2010)" which will do this for you.

- Michael Spencer