Playermet / codegoogle.tart

Automatically exported from code.google.com/p/tart
0 stars 0 forks source link

Can't build on windows as llvm-config can't be build on it #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
LLVM can't build llvm-config on windows as it relies on sed for now to create a 
.inc file.

Can you provide another way to configure tart on windows?
suggest any workaround for now?

Original issue reported on code.google.com by ecy...@gmail.com on 22 Feb 2012 at 3:45

GoogleCodeExporter commented 8 years ago
Same issue here. Some suggestion or help please...

Original comment by xiaoyi...@gmail.com on 14 May 2012 at 9:06

GoogleCodeExporter commented 8 years ago
Well, the "right" solution is to be able to build and run llvm-config on 
windows. I don't suppose anyone is up to tackling that issue, or perhaps asking 
on llvm-dev whether there's any plan to get this working?

Original comment by viri...@gmail.com on 15 May 2012 at 5:02

GoogleCodeExporter commented 8 years ago
It seems I am not the only one who wants to build on windows so here are some 
remarks:
1) Please use a stable version of llvm because I tried 3.0 and 3.1 and I always 
get some compilation erros, for example with lastest there is no llvm::ftostr, 
...
So if you want to simplify build I recommend to stick with the last release and 
check that your code compiles with new releases of llvm.

2)Update your wiki for windows users beacuse commands are slightly different 
from unix, for instance there is no space between D and directive: 
-DCMAKE_INSTALL_PREFIX instead of -D CMAKE_INSTALL_PREFIX. if you want to use 
Visual Studio to compile :

Inside llvm/tools edit the CMakeLists.txt and remove the NOT just before WIN32 
OR MSYS OR CYGWIN

if( WIN32 OR MSYS OR CYGWIN )
  # We currently require 'sed' to build llvm-config, so don't try to build it
  # on pure Win32.
  add_subdirectory(llvm-config)
endif()

Then create with visual a dummy console application that you will call sed.exe 
and that only returns 0.Copy it inside your path (ex :c\Windows).

mkdir llvm-build
cd llvm-build
cmake ../llvm -G "Visual Studio 10" -DCMAKE_INSTALL_PREFIX=../llvm-install 
-DCMAKE_BUILD_TYPE=Release

Then start LLVM.sln and right-click on ALL_BUILD project and select Build.
The project llvm-config won't compile, so you will have to replace manually the 
values inside llvm-config.cpp with the values from BuildVariablesConfigure.sed. 
However at the end it won't work (I wanted to explain all my attemps) because 
llvm-config uses gcc syntax, for example to add library it uses -lMylibrary but 
of course it doesn't work with Visual.

We have a few options here : 
a)try to implement a very simple sed console application that will replace the 
strings and will transform the gcc arguments with the Visual one but I think 
this is a very bad idea and not even sure it will work.

b)Do not use llvm-config as explained here : 
https://groups.google.com/forum/#!topic/llvm-dev/Gbn2I8wfCY8
Someone suggests to not use llvm-config:
llvm-config is a convenience tool for the user, i.e. you don't need it 
for building LLVM/Clang or for your own projects. 

> I found this in may tutorials to easily set-up the command line 
> options for Clang based builds. 

Yes, it is convenient precisely for that. If you are using cmake for 
your own projects, LLVM comes with .cmake modules that do most of the 
job of llvm-config. 

c) use mingw/mingw-w64, not very fond of this option but it might be the only 
option.

Original comment by v.richomme@gmail.com on 11 Nov 2012 at 10:20

GoogleCodeExporter commented 8 years ago
Actually with llvm-3.1 once it's built we have a llvm-install\share\llvm\cmake 
with some interesting cmake files that I suppose could llvm-config.When I look 
at LLVMConfig.cmake I can see : 

...
set(TARGET_TRIPLE "i686-pc-win32")

set(LLVM_TOOLS_BINARY_DIR C:/cygwin/home/Vincent/tart/llvm-build/bin)

set(LLVM_ENABLE_THREADS ON)

set(LLVM_NATIVE_ARCH X86)

set(LLVM_ENABLE_PIC ON)

set(HAVE_LIBDL )
set(HAVE_LIBPTHREAD )
set(LLVM_ON_UNIX 0)
set(LLVM_ON_WIN32 1)

set(LLVM_INSTALL_PREFIX C:/cygwin/home/Vincent/tart/llvm-install)
set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
...

So I suppose this is the way to go.

Original comment by v.richomme@gmail.com on 11 Nov 2012 at 10:29

GoogleCodeExporter commented 8 years ago
I make a patch for CMake generate the inc file for llvm-config without sed. For 
apply it, you will need to go to llvm/tools directory and execute: patch -p0 < 
llvm-config.patch

Original comment by mauroj...@gmail.com on 14 Nov 2012 at 7:19

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for your patch I have tested with llvm-3.1 :

C:\cygwin\home\Vincent\tart\llvm-build>cmake -G "Visual Studio 10" ../llvm -DCMA
KE_INSTALL_PREFIX=../llvm-install -DCMAKE_BUILD_TYPE=Release

When I compile I get the following error :
Error   1   error C2065: 'LLVM_SYSTEM_LIBS' : undeclared 
identifier  C:\cygwin\home\Vincent\tart\llvm\tools\llvm-config\llvm-config.cpp  28
0   1   llvm-config

Inside BuildVariables.inc I have :

#define LLVM_SRC_ROOT "C:/cygwin/home/Vincent/tart/llvm"
#define LLVM_OBJ_ROOT "C:/cygwin/home/Vincent/tart/llvm-build"
#define LLVM_CPPFLAGS "   /MP -D_CRT_SECURE_NO_DEPRECATE 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
-wd4146 -wd4180 -wd4224 -wd4244 -wd4267 -wd4275 -wd4291 -wd4345 -wd4351 -wd4355 
-wd4503 -wd4551 -wd4624 -wd4715 -wd4800 -wd4065 -wd4181 -w14062 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_CFLAGS " /DWIN32 /D_WINDOWS /W3 /Zm1000 /MD /O2 /Ob2 /D NDEBUG  
/MP -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -wd4146 -wd4180 -wd4224 
-wd4244 -wd4267 -wd4275 -wd4291 -wd4345 -wd4351 -wd4355 -wd4503 -wd4551 -wd4624 
-wd4715 -wd4800 -wd4065 -wd4181 -w14062 -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_LDFLAGS " /STACK:10000000 /machine:X86 "
#define LLVM_CXXFLAGS " /DWIN32 /D_WINDOWS /W3 /Zm1000 /GR /EHsc /MD /O2 /Ob2 
/D NDEBUG  /MP -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -wd4146 -wd4180 -wd4224 
-wd4244 -wd4267 -wd4275 -wd4291 -wd4345 -wd4351 -wd4355 -wd4503 -wd4551 -wd4624 
-wd4715 -wd4800 -wd4065 -wd4181 -w14062 -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
#define LLVM_BUILDMODE "Release"
#define LLVM_TARGETS_BUILT "X86"
/* #undef LLVM_SYSTEM_LIBS */

Original comment by v.richomme@gmail.com on 14 Nov 2012 at 9:39

GoogleCodeExporter commented 8 years ago
I have commented the line just to see if the generation of tart projects would 
be possible but I get some errors but I think this has nothing to do with your 
patch :

C:\cygwin\home\Vincent\tart\tart-build>cmake -G "Visual Studio 10" 
-DLLVM_CONFIG=../llvm-install/bin/llvm-config ../tart
-- LLVM llvm-config found at: C:/cygwin/home/Vincent/tart/llvm-install/bin/llvm-
config
CMake Error at linker/CMakeLists.txt:52 (install):
  install Library TARGETS given no DESTINATION!

CMake Error at tools/lexgen/CMakeLists.txt:67 (add_dependencies):
  add_dependencies Adding dependency to non-existent target: lexgenTest

CMake Error at tools/lexgen/CMakeLists.txt:79 (add_dependencies):
  add_dependencies Adding dependency to non-existent target: lexgen

-- Configuring incomplete, errors occurred!

Original comment by v.richomme@gmail.com on 14 Nov 2012 at 10:59

GoogleCodeExporter commented 8 years ago
I have used the version 3.2 of llvm, but I can check if have changes in the 
llvm-config of the version 3.1, possible this defined macro is no more used in 
the svn trunk version.

Original comment by mauroj...@gmail.com on 14 Nov 2012 at 11:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
There was a problem with my change in CMakeLists.txt on llvm-config, if a cmake 
variable is not set, it will not appear on generated inc file.

I have attached the new patch file with the corrections, or only replace the 
CMakeLists.txt of llvm-config for the one that was attached here.

Original comment by mauroj...@gmail.com on 15 Nov 2012 at 12:52

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, unfortunately I don't know if it's because I am using llvm-3.1 but I 
still have errors when generating tart : 
C:\cygwin\home\Vincent\tart\tart-build>cmake -G "Visual Studio 10" 
-DLLVM_CONFIG=../llvm-install/bin/llvm-config ../tart
-- The C compiler identification is MSVC 16.0.40219.1
-- The CXX compiler identification is MSVC 16.0.40219.1
-- 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 include file pthread.h
-- Looking for include file pthread.h - not found
-- Found Threads: TRUE
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - not found
-- Looking for stdarg.h
-- Looking for stdarg.h - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - not found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for execinfo.h
-- Looking for execinfo.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/resource.h
-- Looking for sys/resource.h - not found
-- Looking for libkern/OSAtomic.h
-- Looking for libkern/OSAtomic.h - not found
-- Looking for C++ include new
-- Looking for C++ include new - found
-- Looking for C++ include ctime
-- Looking for C++ include ctime - found
-- Looking for C++ include cxxabi.h
-- Looking for C++ include cxxabi.h - not found
-- Looking for C++ include dlfcn.h
-- Looking for C++ include dlfcn.h - not found
-- Looking for C++ include unwind.h
-- Looking for C++ include unwind.h - not found
-- Looking for C++ include libunwind.h
-- Looking for C++ include libunwind.h - not found
-- Looking for backtrace
-- Looking for backtrace - not found
-- Looking for dladdr
-- Looking for dladdr - not found
-- Looking for posix_memalign
-- Looking for posix_memalign - not found
-- Looking for valloc
-- Looking for valloc - not found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - found
-- Looking for stat
-- Looking for stat - found
-- LLVM llvm-config found at: C:/cygwin/home/Vincent/tart/llvm-install/bin/llvm
config
-- Found LLVM: C:/cygwin/home/Vincent/tart/llvm-install/include
-- Performing Test HAVE_GCC_ATOMICS
-- Performing Test HAVE_GCC_ATOMICS - Failed
-- Performing Test HAVE_GCC_THREAD_LOCAL
-- Performing Test HAVE_GCC_THREAD_LOCAL - Failed
-- Performing Test HAVE_MSVC_THREAD_LOCAL
-- Performing Test HAVE_MSVC_THREAD_LOCAL - Success
-- Check size of int
-- Check size of int - done
-- Check size of long
-- Check size of long - done
-- Check size of size_t
-- Check size of size_t - done
-- Check size of long long
-- Check size of long long - done
-- Check size of void*
-- Check size of void* - done
CMake Error at linker/CMakeLists.txt:52 (install):
  install Library TARGETS given no DESTINATION!

CMake Error at tools/lexgen/CMakeLists.txt:67 (add_dependencies):
  add_dependencies Adding dependency to non-existent target: lexgenTest

CMake Error at tools/lexgen/CMakeLists.txt:79 (add_dependencies):
  add_dependencies Adding dependency to non-existent target: lexgen

-- Configuring incomplete, errors occurred!

Original comment by v.richomme@gmail.com on 15 Nov 2012 at 7:42

GoogleCodeExporter commented 8 years ago
maybe its has something to do with that : 
http://www.cmake.org/pipermail/cmake/2008-September/023876.html

Original comment by v.richomme@gmail.com on 15 Nov 2012 at 7:49

GoogleCodeExporter commented 8 years ago
I'm using MinGW to build llvm, but seems to be a problem on Tart when using 
CMake on Windows, llvm-config appear to been built:

-- LLVM llvm-config found at: C:/cygwin/home/Vincent/tart/llvm-install/bin/llvm
config

The suggested solution is to add RUNTIME on install command, here is an thread 
explain that: http://mail.kde.org/pipermail/kde-windows/2009-March/003558.html

Original comment by mauroj...@gmail.com on 15 Nov 2012 at 8:14

GoogleCodeExporter commented 8 years ago
yes it fixes the first error when I changed the tart\linker\CMakeLists.txt like 
that :

install(TARGETS gc reflector LIBRARY DESTINATION lib/tart/plugin
                             ARCHIVE DESTINATION lib/tart/plugin
                 RUNTIME DESTINATION lib/tart/plugin)

but dont' know how to fix non-existent target lexgenTest and lexgen.

Original comment by v.richomme@gmail.com on 15 Nov 2012 at 8:55

GoogleCodeExporter commented 8 years ago
What version of llvm do you use by the way ? 

Original comment by v.richomme@gmail.com on 15 Nov 2012 at 11:01

GoogleCodeExporter commented 8 years ago
I have tested llvm-3.1 and llvm-3.2, but not tried to build tart.

Problem is the CMake function add_tart_executable on 
tools/lexgen/CMakeLists.txt that define the dependence file name with a suffix 
(this suffix will be set on Windows).

Make these changes:

add_dependencies(lexgenTest libstd libtesting libLexGenShared libLexGenGen 
libLexGenTest)

to

add_dependencies(lexgenTest${CMAKE_EXECUTABLE_SUFFIX} libstd libtesting 
libLexGenShared libLexGenGen libLexGenTest)

and change this too:

add_dependencies(lexgen libstd libopts libLexGenShared libLexGenGen 
libLexGenApp)

to

add_dependencies(lexgen${CMAKE_EXECUTABLE_SUFFIX} libstd libopts 
libLexGenShared libLexGenGen libLexGenApp)

Or, CMake add exe suffix automatically on Windows, if you change:

set(EXE_FILE ${Name}${CMAKE_EXECUTABLE_SUFFIX})

to:

set(EXE_FILE ${Name})

Can work, but I have not tested it...

Original comment by mauroj...@gmail.com on 15 Nov 2012 at 11:46