clang++ unable to find strerror_s in msvcrt.dll on winxp/2k3

Bug #1388627 reported by blueshell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cheerp
Fix Released
Low
Unassigned

Bug Description

clang++ got a error:
can't find strerror_s in msvcrt.dll
on win xp/2k3 32bit.
however it works well in win2k8R2 64bit.

I find a similar problem on other projects.
http://sourceforge.net/p/freemat/bugs/588/

FWIW
an bug report for Clang
http://sourceforge.<email address hidden>/
maybe a resolution
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110131/115872.html

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

The strerror_s function is not available on older versions of windows. The bug is real and I am confirming it, but we don't have plan to make Windows XP compatible builds. You may be able to build cheerp from sources directly on Windows XP.

Changed in cheerp:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
blueshell (shell3000) wrote :

The build guide is wrote for Linux users.
i am not familiar with Linux. can you update a guide for windows?
but i will try to build clang++ and clang with your guide.

Revision history for this message
blueshell (shell3000) wrote :

According to the experience, the solution to run in winXP/2k3 with no code changed:

1 install VS2012 SP1
2 set PlatformToolset to Visual Studio 2012 - Windows XP (v110_xp)
3 set RuntimeLibrary to MultiThreaded

or just batch replace *.vcxproj
from <PlatformToolset>v110</PlatformToolset> to <PlatformToolset>v110_xp</PlatformToolset>
from <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> to <RuntimeLibrary>MultiThreaded</RuntimeLibrary>

I do not find the command in cmake to make above arguments as default.

but i got lots of compile error on VS2012;and i only find the project to generate clang,but no clang++

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

If you are able to generate the clang executable you are actually done. clang++ on Windows is simply a copy of the same executable with a different name. It would be very helpful if you could document the procedure to build on Windows, including for XP, on our wiki:

https://github.com/leaningtech/cheerp-wiki/wiki/Windows-build-instructions

Revision history for this message
blueshell (shell3000) wrote :

yes , i change some code to improved compatibility for vs2012,now it can be run in xp;
the file size is 18M only,but the file you provided is 45M.did i miss something?

but when i replace all things in cheerp\bin

and run the example i got a error.

example.cpp:3:10: fatal error: 'cheerp/clientlib.h' file not found

did i override something important?

i will write a wiki document for my process.

Revision history for this message
blueshell (shell3000) wrote :

if i add arg -I"C:\cheerp\include\client" for clang++
i got another error

 C:\cheerp\include\client\cheerp/types.h:24:10: fatal error: 'utility' file not
      found
#include <utility>

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

What is the cmake command you use to create the visual studio projects?

Also, please create an empty file, for example "empty.cpp" and post the result of the following command

    /opt/cheerp/bin/clang++ -target cheerp -E -x c++ -v empty.cpp

What is the command you are using to build the example?

The different in size depends on the fact that our build is a static build cross-compiled using Mingw, while you are doing regular build. Don't worry about the smaller size, it should work.

Revision history for this message
blueshell (shell3000) wrote :

I'v update the wiki with my step and convert log.
i use cmake as follows
cmake -DCMAKE_INSTALL_PREFIX=/opt/cheerp -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;CheerpBackend;X86" ..

i made empty file named empty.cpp and call
clang++ -target cheerp -E -x c++ -v empty.cpp
the info is:

clang version 3.5.0
Target: cheerp--webbrowser
Thread model: posix
 "C:\cheerp\bin\clang++.exe" -cc1 -triple cheerp--webbrowser -E -disable-free -d
isable-llvm-verifier -main-file-name empty.cpp -mrelocation-model static -mdisab
le-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -v -resource-dir
 "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0" -internal-isystem /opt/cheerp/include/
c++/v1 -internal-isystem "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0\\include" -inte
rnal-externc-isystem /opt/cheerp/include -internal-externc-isystem /opt/cheerp/i
nclude/client -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-di
r "C:\\JSExample" -ferror-limit 19 -fmessage-length 80 -mstackrealign -fno-rtti
-fno-threadsafe-statics -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-dia
gnostics -vectorize-slp -o - -x c++ empty.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target i686-pc-win32
ignoring nonexistent directory "/opt/cheerp/include/c++/v1"
ignoring nonexistent directory "/opt/cheerp/include"
ignoring nonexistent directory "/opt/cheerp/include/client"
ignoring nonexistent directory "/opt/cheerp/include/common"
#include "..." search starts here:
#include <...> search starts here:
 C:\cheerp\bin\..\lib\clang\3.5.0\include
End of search list.
# 1 "empty.cpp"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 148 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "empty.cpp" 2

Revision history for this message
blueshell (shell3000) wrote :

i think i need to change

#define LLVM_PREFIX "/opt/cheerp"
llvm\Config\config.h
add
llvm\Config\llvm-config.h

i think i need change the
cmake -DCMAKE_INSTALL_PREFIX=/opt/cheerp also?

but which command should i use?

Revision history for this message
blueshell (shell3000) wrote :

I find that the path is hard code as "getProgramPaths().push_back(LLVM_PREFIX "/bin");"
i think we should get the path of the executable file runtime and generate the include path and library path.

I simply #define LLVM_PREFIX c:/cheerp
and i am checking whether it works.

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

You should change the prefix for the windows build, the right command is

cmake -DCMAKE_INSTALL_PREFIX=c:\cheerp -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;CheerpBackend;X86" ..

LLVM_PREFIX is automatically defined from the install prefix you tell cmake

Revision history for this message
blueshell (shell3000) wrote :

yes, i am compiling.
but i think the better way is get the path of the executable file runtime ,and generate the include path and library path.
or else, if i install the software to d:\cheerp\ the software will not find the correct path.

Revision history for this message
blueshell (shell3000) wrote :
Revision history for this message
blueshell (shell3000) wrote :

new problem
C:\cheerp\bin\clang++.exe -v -target cheerp example.cpp -o example.js

i got a error

clang version 3.5.0
Target: cheerp--webbrowser
Thread model: posix
 "C:\cheerp\bin\clang++.exe" -cc1 -triple cheerp--webbrowser -emit-llvm-bc -disa
ble-free -disable-llvm-verifier -main-file-name example.cpp -mrelocation-model s
tatic -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -v
-resource-dir "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0" -internal-isystem c:/chee
rp/include/c++/v1 -internal-isystem "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0\\inc
lude" -internal-externc-isystem c:/cheerp/include -internal-externc-isystem c:/c
heerp/include/client -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compila
tion-dir "C:\\JSExample" -ferror-limit 19 -fmessage-length 80 -mstackrealign -fn
o-rtti -fno-threadsafe-statics -fobjc-runtime=gcc -fdiagnostics-show-option -fco
lor-diagnostics -vectorize-slp -o "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\examp
le-79d681.o" -x c++ example.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
 c:/cheerp/include/c++/v1
 C:\cheerp\bin\..\lib\clang\3.5.0\include
 c:/cheerp/include
 c:/cheerp/include/client
 c:/cheerp/include/common
End of search list.
 "C:\cheerp\bin\llvm-link.exe" -o "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\examp
le-686c05.bc" "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\example-79d681.o" c:/chee
rp/lib/libc.bc c:/cheerp/lib/libm.bc c:/cheerp/lib/libc++.bc c:/cheerp/lib/libcx
xabi.bc
error: deprecated attribute found in LLVM IR, please rebuild using an updated ve
rsion of Cheerp
C:\cheerp\bin\llvm-link.exe: c:/cheerp/lib/libc.bc: error: Invalid value
C:\cheerp\bin\llvm-link.exe: error loading file 'c:/cheerp/lib/libc.bc'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invoca
tion)

Revision history for this message
blueshell (shell3000) wrote :

can you give me the git version of Cheerp 1.0?

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

From a cloned git repository you can extract any version using the "git checkout" command, for example

git checkout cheerp-1.0

I have noticed only now that we have not published source packages for LLVM/clang version 1.0. I'm going to fix this, but in the mean time please use the above command to retrieve version 1.0. Remember that, since llvm and clang are two different repositories you need to do "git checkout cheerp-1.0" in both of them.

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

You can now find the 1.0 Cheerp source for LLVM and clang here: https://launchpad.net/cheerp/+download

Revision history for this message
blueshell (shell3000) wrote :

Ok.i will try it.
is my libc.bc(released in 1.0 version) too old for the new clang++?
and then i got the error?

Revision history for this message
blueshell (shell3000) wrote :

i'v found the different.
in llvm\Bitcode\LLVMBitCodes.h enum AttributeKindCodes
in v1.0 ATTR_KIND_TYPED_INTRINSIC = 41,
and in the lastest version ATTR_KIND_RESERVED = 41,

so i think it got a error because cheerp/lib/libc.bc is old.
so if i need to use lastest version , i need compile those libs also?

Revision history for this message
blueshell (shell3000) wrote :

cheerp-1.0
do not have
#include "llvm/Cheerp/ReplaceNopCasts.h"
#include "llvm/Cheerp/StructMemFuncLowering.h"
those two files.
i copied them from higher version. hopes nothing incompatible form 1.0 version.

Revision history for this message
blueshell (shell3000) wrote :

CGBuiltin.cpp(4514): error C2039: “cheerp_make_complete_object"

lots of compile error.
plz publish source packages of v1.0.

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

The source package is now available here:

https://launchpad.net/cheerp/trunk/cheerp-1.0/+download/cheerp-llvm-clang-1.0.tar.gz

The binary file format has indeed changed since 1.0, but I'm not sure if building the libc library is feasible on windows.

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

I'm currently working on a build fix to support for XP and 2k3. I will backport the fix and make a new 1.0 windows build after testing.

Changed in cheerp:
status: Confirmed → In Progress
Revision history for this message
blueshell (shell3000) wrote :

i can't generate libc.bc etc. for lastest version,because the makefile and .sh is only for Linux.
can you give me the lastest *.bc of libs?

I generate 1.0 execute files with "cheerp-llvm-clang-1.0.tar.gz"
and get a error
llvm-link.exe: linked module is broken!

C:\cheerp\bin\clang++.exe -v -target cheerp example.cpp -o example.js

clang version 3.5.0
Target: cheerp--webbrowser
Thread model: posix
 "C:\cheerp\bin\clang++.exe" -cc1 -triple cheerp--webbrowser -emit-llvm-bc -disa
ble-free -disable-llvm-verifier -main-file-name example.cpp -mrelocation-model s
tatic -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -v
-resource-dir "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0" -internal-isystem c:/chee
rp/include/c++/v1 -internal-isystem "C:\\cheerp\\bin\\..\\lib\\clang\\3.5.0\\inc
lude" -internal-externc-isystem c:/cheerp/include -internal-externc-isystem c:/c
heerp/include/client -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compila
tion-dir "C:\\JSExample" -ferror-limit 19 -fmessage-length 80 -mstackrealign -fn
o-rtti -fno-threadsafe-statics -fobjc-runtime=gcc -fdiagnostics-show-option -fco
lor-diagnostics -vectorize-slp -o "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\examp
le-8063a9.o" -x c++ example.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
 c:/cheerp/include/c++/v1
 C:\cheerp\bin\..\lib\clang\3.5.0\include
 c:/cheerp/include
 c:/cheerp/include/client
 c:/cheerp/include/common
End of search list.
 "C:\cheerp\bin\llvm-link.exe" -o "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\examp
le-f8ca27.bc" "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp\\example-8063a9.o" c:/chee
rp/lib/libc.bc c:/cheerp/lib/libm.bc c:/cheerp/lib/libc++.bc c:/cheerp/lib/libcx
xabi.bc
C:\cheerp\bin\llvm-link.exe: linked module is broken!
clang++.exe: error: linker command failed with exit code 1 (use -v to see invoca
tion)

Revision history for this message
blueshell (shell3000) wrote :

I'v complete the version.
and compile "example.cpp" successfully in windows 2003.

here is a package build from src 1.0.
maybe someone else needed.

Revision history for this message
blueshell (shell3000) wrote :

notice:
llvm-tblgen.exe crash when generate ARMCommonTableGen and X86CommonTableGen in vs2012 windows 8.1

Building X86GenRegisterInfo.inc...
Building ARMCommonTableGen.inc...

I don't know what those 2 projects are.
but clang++ and llvm-link are generate successfully.

Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :
Changed in cheerp:
status: In Progress → Fix Released
Revision history for this message
Alessandro Pignotti (a-pignotti) wrote :

By the way, current git master of Cheerp also builds with VS2012 without any modification

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.