mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Makefile.clangcl: use llvm-rc instead of windres.
Previously I was using clang-cl as my compiler, lld as my linker, and GNU windres as my resource compiler, which made a confusing hybrid of the LLVM and GNU toolchains. This was because llvm-rc had about four missing features that stopped it being able to handle PuTTY's resource files. (Some dialog control types; dialog class names; handling preprocessor output without getting confused by line markers and snippets of stray C; not complaining about the DISCARDABLE keyword. Although admittedly I could have dealt with the last of those by just removing it from my .rc files, because it's pointless anyway.) In the past month, the llvm-rc developers have been hard at work, and now it has _all_ those features! So now I can switch over to a purely LLVM-based toolchain for my Windows builds, which is easier to set up (and easier to tell other people how to set up, since they get it for free with the rest of LLVM); doesn't have a nominal architecture dependency (windres has to built against a particular flavour of binutils); and produces bit-identical output to Visual Studio's resource compiler as far as I can see (whereas windres is more in the 'close enough' area). This needed a small makefile restructuring, because unlike windres, llvm-rc doesn't have a built-in option to run the resource file through the preprocessor. So now Makefile.clangcl has separate rules to preprocess $tool.rc into $tool.rcpp and then compile the latter into $tool.res.
This commit is contained in:
parent
b851d748be
commit
bf0cf984cd
44
mkfiles.pl
44
mkfiles.pl
@ -448,14 +448,9 @@ if (defined $makefiles{'clangcl'}) {
|
||||
# using the real Visual Studio header files and libraries. In
|
||||
# order to run it, you will need:
|
||||
#
|
||||
# - MinGW windres on your PATH.
|
||||
# * On Ubuntu as of 16.04, you can apt-get install
|
||||
# binutils-mingw-w64-x86-64 and binutils-mingw-w64-i686
|
||||
# which will provide (respectively) 64- and 32-bit versions,
|
||||
# under the names to which RCCMD is defined below.
|
||||
# - clang-cl and lld-link on your PATH.
|
||||
# - clang-cl, llvm-rc and lld-link on your PATH.
|
||||
# * I built these from the up-to-date LLVM project trunk git
|
||||
# repositories, as of 2017-02-05.
|
||||
# repositories, as of 2018-05-29.
|
||||
# - case-mashed copies of the Visual Studio include directories.
|
||||
# * On a real VS installation, run vcvars32.bat and look at
|
||||
# the resulting value of %INCLUDE%. Take a full copy of each
|
||||
@ -521,23 +516,22 @@ if (defined $makefiles{'clangcl'}) {
|
||||
open OUT, ">$makefiles{'clangcl'}"; select OUT;
|
||||
print
|
||||
"# Makefile for cross-compiling $project_name using clang-cl, lld-link,\n".
|
||||
"# and MinGW's windres, using GNU make on Linux.\n".
|
||||
"# and llvm-rc, using GNU make on Linux.\n".
|
||||
"#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
|
||||
"# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
|
||||
print $help;
|
||||
print
|
||||
"\n".
|
||||
"CCCMD = clang-cl\n".
|
||||
"RCCMD = llvm-rc\n".
|
||||
"ifeq (\$(Platform),x64)\n".
|
||||
"CCTARGET = x86_64-pc-windows-msvc18.0.0\n".
|
||||
"RCCMD = x86_64-w64-mingw32-windres\n".
|
||||
"else\n".
|
||||
"CCTARGET = i386-pc-windows-msvc18.0.0\n".
|
||||
"RCCMD = i686-w64-mingw32-windres\n".
|
||||
"endif\n".
|
||||
"CC = \$(CCCMD) --target=\$(CCTARGET)\n".
|
||||
&splitline("RC = \$(RCCMD) --preprocessor=\$(CCCMD) ".
|
||||
"--preprocessor-arg=/TC --preprocessor-arg=/E")."\n".
|
||||
"RC = \$(RCCMD) /c 1252 \n".
|
||||
"RCPREPROC = \$(CCCMD) /P /TC\n".
|
||||
"LD = lld-link\n".
|
||||
"\n".
|
||||
"# C compilation flags\n".
|
||||
@ -547,8 +541,8 @@ if (defined $makefiles{'clangcl'}) {
|
||||
"/D_CRT_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS").
|
||||
"\n".
|
||||
"LFLAGS = /incremental:no /dynamicbase /nxcompat\n".
|
||||
&splitline("RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
|
||||
" -DWIN32 -D_WIN32 -DWINVER=0x0400")."\n".
|
||||
&splitline("RCPPFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs).
|
||||
" -DWIN32 -D_WIN32 -DWINVER=0x0400")." \$(RCFL)\n".
|
||||
"\n".
|
||||
&def($makefile_extra{'clangcl'}->{'vars'}) .
|
||||
"\n".
|
||||
@ -568,17 +562,29 @@ if (defined $makefiles{'clangcl'}) {
|
||||
"/subsystem:$subsys\$(SUBSYSVER) ".
|
||||
"\$(EXTRA_$subsys) $objstr")."\n\n";
|
||||
}
|
||||
my $rc_pp_rules = "";
|
||||
foreach $d (&deps("\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", $dirpfx, "/", "vc")) {
|
||||
$extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : [];
|
||||
print &splitline(sprintf("%s: %s", $d->{obj},
|
||||
join " ", @$extradeps, @{$d->{deps}})), "\n";
|
||||
my $rule;
|
||||
my @deps = @{$d->{deps}};
|
||||
if ($d->{obj} =~ /\.res$/) {
|
||||
print "\t\$(RC) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n";
|
||||
my $rc = $deps[0];
|
||||
my $rcpp = $rc;
|
||||
$rcpp =~ s!.*/!!;
|
||||
$rcpp =~ s/\.rc$/.rcpp/;
|
||||
$rcpp = "\$(BUILDDIR)" . $rcpp;
|
||||
$rule = "\$(RC) ".$rcpp." /FO ".$d->{obj};
|
||||
$rc_pp_rules .= "$rcpp: $rc\n" .
|
||||
"\t\$(RCPREPROC) \$(RCPPFLAGS) /Fi\$\@ \$<\n\n";
|
||||
$deps[0] = $rcpp;
|
||||
} else {
|
||||
print "\t\$(CC) /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<\n\n";
|
||||
$rule = "\$(CC) /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<";
|
||||
}
|
||||
print &splitline(sprintf("%s: %s", $d->{obj},
|
||||
join " ", @$extradeps, @deps)), "\n";
|
||||
print "\t" . $rule . "\n\n";
|
||||
}
|
||||
print "\n";
|
||||
print "\n" . $rc_pp_rules;
|
||||
print &def($makefile_extra{'clangcl'}->{'end'});
|
||||
print "\nclean:\n".
|
||||
&splitline("\trm -f \$(BUILDDIR)*.obj \$(BUILDDIR)*.exe ".
|
||||
|
Loading…
Reference in New Issue
Block a user