GNOME Bugzilla – Bug 690456
Support configurable pkg-config so can cross-compile
Last modified: 2014-07-14 16:34:00 UTC
Created attachment 231838 [details] [review] Support configurable pkg-config command so can cross compile To support cross compiling both the compiler and pkg-config need to be able to be specified. valac already supports configuring the C compiler using --cc and $CC, this patch adds support for --pkg-config and $PKG_CONFIG. e.g. if you have a simple vala program that you want to compile for ARM from an amd64 machine you might do: valac --cc=arm-linux-gnueabihf-gcc --pkg-config=arm-linux-gnueabihf-pkg-config foo.vala or CC=arm-linux-gnueabihf-gcc PKG_CONFIG=arm-linux-gnueabihf-pkg-config valac foo.vala
Note that the suggested use of a PKG_CONFIG variable is based on the pkg.m4 macros, which use the cross-building-aware AC_PATH_TOOL(). This is done entirely for the benefit of those who *aren't* using the standard automake rules for vala, but it's probably a good idea to be as consistent as possible here, so it's suggested to use PKG_CONFIG rather than trying to permute the settings externally with a PKG_CONFIG_PATH environment variable. Please see http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/raring/pkg-config/raring/view/head:/debian/pkg-config-crosswrapper for a sample implementation of a cross-pkg-config that works this way.
I guess this is for bake? Wouldn't it make more sense to just have valac do the vala->C compilation, then reuse the C support for actually compiling the C? AFAIK that's what all the other build systems do...
No, this was just because at the time I think I was trying to cross compile some Vala code and I couldn't get it to work. Exactly what I was trying to do seems to have been lost in the mists of time... I think I was just trying to use valac directly for some small test program and realised it couldn't work due to the hard-coded values. Yes, Bake does the convert to C and do everything as per normal.
This is not a high priority feature, I think I just happened to have an opportunity to make valac more consistent and wrote the patch. It doesn't bother me if the patch is accepted or not, though others may hit the same problem.
(In reply to comment #4) > This is not a high priority feature, I think I just happened to have an > opportunity to make valac more consistent and wrote the patch. It doesn't > bother me if the patch is accepted or not, though others may hit the same > problem. Yeah, bug #685266 is pretty similar, so I don't think it's just you. The variable definitely makes sense. I'm not too enthusiastic about adding the argument, but I guess it doesn't really matter. Luca, any objections?
Review of attachment 231838 [details] [review]: I don't see a reason neither for --cc nor for --pkgconfig, since you can simply tweak PATH or CC or PKG_CONFIG (in this patch). However, it it's fine apart a couple of changes. ::: codegen/valaccodecompiler.vala @@ +49,3 @@ * @param context a code context */ + public void compile (CodeContext context, string? cc_command, string[] cc_options, string? pkg_config_command) { Please make pkg_config_command null by default, otherwise we break libvala uselessly. @@ +56,3 @@ + } + + string pc = pkg_config_command + " --cflags"; Broken indentation here.
Created attachment 280474 [details] [review] Support configurable pkg-config command so can cross compile Use default value in parameter and fix indentation.
commit 7a48bd244dda8beea79e2da72f9c482326e855ff Author: Robert Ancell <robert.ancell@canonical.com> Date: Wed Dec 19 11:04:49 2012 +1300 compiler: Support configurable pkg-config command so can cross compile Fixes bug 690456 This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.