Commit ab025dc5 authored by cremno's avatar cremno

visualcpp toolchain: change compiler/linker flags

with these flags visualcpp should behave more like the gcc toolchain

c:
- produce debug information
- optimize for speed instead of disabling optimization
- use non-debug version of Microsoft's C library
- remove unused and unnecessary macro definitions
cxx:
- separate C and C++ (#1594)
- specify kind of exception handling (see warning C4530)
linker:
- produce debug information
- disable incremental linking and re-enable optimizations
parent 2f20463b
MRuby::Toolchain.new(:visualcpp) do |conf| MRuby::Toolchain.new(:visualcpp) do |conf|
[conf.cc, conf.cxx].each do |cc| [conf.cc].each do |cc|
cc.command = ENV['CC'] || 'cl.exe' cc.command = ENV['CC'] || 'cl.exe'
cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /D_DEBUG /MDd /Zi /Od /RTC1 /DHAVE_STRING_H /DNO_GETTIMEOFDAY /D_CRT_SECURE_NO_WARNINGS)] cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /D_CRT_SECURE_NO_WARNINGS)]
cc.include_paths = ["#{MRUBY_ROOT}/include"] cc.include_paths = ["#{MRUBY_ROOT}/include"]
cc.defines = %w(DISABLE_GEMS) cc.defines = %w(DISABLE_GEMS)
cc.option_include_path = '/I%s' cc.option_include_path = '/I%s'
...@@ -9,26 +9,36 @@ MRuby::Toolchain.new(:visualcpp) do |conf| ...@@ -9,26 +9,36 @@ MRuby::Toolchain.new(:visualcpp) do |conf|
cc.compile_options = "%{flags} /Fo%{outfile} %{infile}" cc.compile_options = "%{flags} /Fo%{outfile} %{infile}"
end end
[conf.cxx].each do |cxx|
cxx.command = ENV['CXX'] || 'cl.exe'
cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /EHsc /D_CRT_SECURE_NO_WARNINGS)]
cxx.include_paths = ["#{MRUBY_ROOT}/include"]
cxx.defines = %w(DISABLE_GEMS)
cxx.option_include_path = '/I%s'
cxx.option_define = '/D%s'
cxx.compile_options = "%{flags} /Fo%{outfile} %{infile}"
end
conf.linker do |linker| conf.linker do |linker|
linker.command = ENV['LD'] || 'link.exe' linker.command = ENV['LD'] || 'link.exe'
linker.flags = [ENV['LDFLAGS'] || %w(/nologo)] linker.flags = [ENV['LDFLAGS'] || %w(/NOLOGO /DEBUG /INCREMENTAL:NO /OPT:ICF /OPT:REF)]
linker.libraries = %w() linker.libraries = %w()
linker.library_paths = %w() linker.library_paths = %w()
linker.option_library = '%s.lib' linker.option_library = '%s.lib'
linker.option_library_path = '/LIBPATH:%s' linker.option_library_path = '/LIBPATH:%s'
linker.link_options = "%{flags} /OUT:%{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}" linker.link_options = "%{flags} /OUT:%{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}"
end end
conf.archiver do |archiver| conf.archiver do |archiver|
archiver.command = ENV['AR'] || 'lib.exe' archiver.command = ENV['AR'] || 'lib.exe'
archiver.archive_options = '/nologo /OUT:%{outfile} %{objs}' archiver.archive_options = '/nologo /OUT:%{outfile} %{objs}'
end end
conf.yacc do |yacc| conf.yacc do |yacc|
yacc.command = ENV['YACC'] || 'bison.exe' yacc.command = ENV['YACC'] || 'bison.exe'
yacc.compile_options = '-o %{outfile} %{infile}' yacc.compile_options = '-o %{outfile} %{infile}'
end end
conf.gperf do |gperf| conf.gperf do |gperf|
gperf.command = 'gperf.exe' gperf.command = 'gperf.exe'
gperf.compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}' gperf.compile_options = '-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" %{infile} > %{outfile}'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment