[Ur] Patches to compile Ur/Web with clang
austin seipp
as at hacks.yi.org
Fri Jun 17 11:37:37 EDT 2011
Hello,
I've been learning Ur/Web a bit recently, and on my OS X machine I
encountered some failures when attempting to build the compiler using
clang for the C code.
So I made up a small patch and fixed the build issues. The primary
culprit is that clang is a bit noisier with -Wall by default than GCC
is. It warns specifically about the usage of '%n' string format
specifiers in the source code, which it considers unsafe. So it makes
sure the C compiler is also passed the flag '-Wno-format-security'
which will silence it. There was also an improper implicit cast
between two types which was also fixed.
The patch also makes ./configure.ac output the C compiler to be used
in config.sml. When compiling (compiler.sml/compileC) it uses the
compiler configured at compile time. By default this is GCC, but in
order to use clang, you only need to do:
$ CC=clang ./configure ...
$ make install
Then, when compiling your projects, the resulting C files generated by
the Ur/Web compiler are compiled and linked with clang.
I made a mirror of the Ur/Web mercurial repository on github a few
days ago since I'm much more familiar with git than hg (and I prefer
browsing source with it than the default hg interface,) and so I was
prone to make the changes there; sorry. You can see the full diff that
enables all of the above here:
https://github.com/thoughtpolice/urweb/commit/e8fa4cdfb031774a55a421272a0f9aaf4d8edee4
These are very small. If needed, I can make a mirror of my changes on
a bitbucket repository and they can be pulled into the master
repository. But they're small enough you may want to just cherry pick
the changes by hand. Alternatively I could probably just generate a
unified diff, if that's easier.
I did not commit the changes that 'autoreconf' made on my machine to
things like the Makefiles or configure, naturally (the diff was large,
because of differing autoconf/automake versions, etc.) I figured that
you (Adam) would like to keep those scripts in sync with your own
development machine with your repository, so I figured you'd want to
regenerate all that yourself.
These fixes are relatively small, so I hope they're acceptable. OS X
as of the new Lion release apparently drops GNU GCC by default for the
system compiler (instead opting for llvm-gcc, and symlinking it to
'gcc' on the system,) but considering llvm-gcc is already considered
deprecated, it wouldn't surprise me if shortly in the future it was
always using clang by default. So OS X users will eventually want this
anyway I bet.
--
Regards,
Austin
More information about the Ur
mailing list