After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 690456 - Support configurable pkg-config so can cross-compile
Support configurable pkg-config so can cross-compile
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: general
0.18.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-12-18 22:12 UTC by Robert Ancell
Modified: 2014-07-14 16:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support configurable pkg-config command so can cross compile (3.67 KB, patch)
2012-12-18 22:12 UTC, Robert Ancell
needs-work Details | Review
Support configurable pkg-config command so can cross compile (3.67 KB, patch)
2014-07-11 08:01 UTC, Robert Ancell
none Details | Review

Description Robert Ancell 2012-12-18 22:12:33 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
Comment 1 Steve Langasek 2012-12-18 23:26:17 UTC
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.
Comment 2 Evan Nemerson 2014-06-27 20:13:57 UTC
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...
Comment 3 Robert Ancell 2014-06-28 00:21:31 UTC
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.
Comment 4 Robert Ancell 2014-06-28 00:23:09 UTC
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.
Comment 5 Evan Nemerson 2014-06-28 00:55:24 UTC
(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?
Comment 6 Luca Bruno 2014-06-28 07:44:52 UTC
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.
Comment 7 Robert Ancell 2014-07-11 08:01:00 UTC
Created attachment 280474 [details] [review]
Support configurable pkg-config command so can cross compile

Use default value in parameter and fix indentation.
Comment 8 Luca Bruno 2014-07-14 16:34:00 UTC
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.