Bug 1161338 - ruby-libvirt: FTBS on Mac OS
Summary: ruby-libvirt: FTBS on Mac OS
Keywords:
Status: ASSIGNED
Alias: None
Product: Virtualization Tools
Classification: Community
Component: ruby-libvirt
Version: unspecified
Hardware: x86_64
OS: Mac OS
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Privoznik
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-06 23:13 UTC by Mark Heily
Modified: 2018-07-18 14:32 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)
workaround to fix the build (423 bytes, patch)
2014-11-06 23:14 UTC, Mark Heily
no flags Details | Diff
improved patch to fix the build (362 bytes, patch)
2015-03-16 18:36 UTC, Mark Heily
no flags Details | Diff

Description Mark Heily 2014-11-06 23:13:27 UTC
Description of problem:

On Mac OS X 10.10, the ruby-libvirt gem fails to compile.

Version-Release number of selected component (if applicable):

0.5.2

How reproducible:

Always

Steps to Reproduce:
1. git clone git://libvirt.org/ruby-libvirt.git
2. cd ruby-libvirt
3. rake build

Actual results:

The gem should build.


Expected results:

domain.c:5439:29: error: use of undeclared identifier
      'VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK'
                    INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK));
... followed by similar errors


Additional info:

Comment 1 Mark Heily 2014-11-06 23:14:25 UTC
Created attachment 954697 [details]
workaround to fix the build

Here is a patch that fixes the build. It does not fix the underlying problem with extconf.rb

Comment 2 Mark Heily 2014-11-06 23:16:33 UTC
See below for the relevant portion of the ext/libvirt/mkmf.log logfile.

Note that the configuration test program does not include <libvirt/libvirt-qemu.h>, so clang throws an error.


---- snip -----


have_library: checking for virDomainQemuMonitorCommand() in -lvirt-qemu... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS -I/usr/local/Cellar/libvirt/1.2.8/include conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -L/usr/local/Cellar/libvirt/1.2.8/lib   -arch x86_64 -arch i386   -lvirt -lruby.2.0.0 -lvirt-qemu  -lvirt -lpthread -ldl -lobjc "
conftest.c:5:57: error: use of undeclared identifier 'virDomainQemuMonitorCommand'
int t(void) { void ((*volatile p)()); p = (void ((*)()))virDomainQemuMonitorCommand; return 0; }
                  
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))virDomainQemuMonitorCommand; return 0; }
 6: int main(int argc, char **argv)
 7: {
 8:   if (argc > 1000000) {
 9:     printf("%p", &t);
10:   }
11: 
12:   return 0;
13: }
/* end */

Comment 3 Mark Heily 2014-11-07 21:20:46 UTC
Here's another failure to detect a valid symbol. This time, it points to a mismatch between i386 and x86_64.

have_func: checking for virStoragePoolIsActive() in libvirt/libvirt.h... -------------------- no

"xcrun clang -o conftest -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin14 -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -g -Os -pipe -DHAVE_GCC_SYNC_BUILTINS -I/usr/local/Cellar/libvirt/1.2.8/include conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib -L. -L/usr/local/lib -L/usr/local/Cellar/libvirt/1.2.8/lib   -arch x86_64 -arch i386   -lvirt -lruby.2.0.0  -lvirt -lpthread -ldl -lobjc "
ld: warning: ignoring file /usr/local/lib/libvirt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libvirt.dylib
Undefined symbols for architecture i386:
  "_virStoragePoolIsActive", referenced from:
      _t in conftest-58b4f3.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Comment 4 Mark Heily 2014-11-07 21:24:39 UTC
Possible fix:

When I run this, it appears to build correctly:

ARCHFLAGS='-arch x86_64' gem install ruby-libvirt

Comment 5 Michal Privoznik 2015-02-19 08:57:54 UTC
This should be against ruby-libvirt rather than libvirt itself.

Comment 6 Michal Privoznik 2015-02-19 08:59:40 UTC
Mark, do you mind posting a patch? Sometimes it's the best way to get things moving.

Comment 7 Mark Heily 2015-03-16 18:36:32 UTC
Created attachment 1002448 [details]
improved patch to fix the build

Here's a patch that works for me.

I'm able to run "rake build" and then "rake gem" to generate a gem on an OS/X 10.10 system.

Comment 8 Michal Privoznik 2015-03-17 13:08:43 UTC
I've proposed the patch upstream:

https://www.redhat.com/archives/libvir-list/2015-March/msg00818.html

Comment 9 Victor Volle 2015-11-02 10:06:38 UTC
Instead of the obsolete patch from comment 1 I would propose

diff --git a/ext/libvirt/extconf.rb b/ext/libvirt/extconf.rb
index d5f4d74..a87909f 100644
--- a/ext/libvirt/extconf.rb
+++ b/ext/libvirt/extconf.rb
@@ -479,7 +479,7 @@ libvirt_funcs.each { |f| have_func(f, "libvirt/libvirt.h") }
 libvirt_consts.each { |c| have_const(c, ["libvirt/libvirt.h"]) }
 virterror_consts.each { |c| have_const(c, ["libvirt/virterror.h"]) }
 if find_header("libvirt/libvirt-qemu.h")
-  have_library("virt-qemu", "virDomainQemuMonitorCommand")
+  have_library("virt-qemu", "virDomainQemuMonitorCommand", "libvirt/libvirt-qemu.h")
   libvirt_qemu_funcs.each { |f| have_func(f, "libvirt/libvirt-qemu.h") }
   libvirt_qemu_consts.each { |c| have_const(c, ["libvirt/libvirt-qemu.h"]) }
 end

this should correctly determine if libvirt-qemu is available

Comment 10 Victor Volle 2015-11-02 12:15:35 UTC
fully patched version at https://github.com/kontrafiktion/ruby-libvirt/tree/bug-1161338

1) the patch to extconf.rb to correctly determine whether libvirt-qemu is installed
2) the patch to Rakefile to correctly set the ARCH_FLAG on OS X

Comment 11 Sebastian Szary 2016-02-12 00:08:25 UTC
Corrected patch to include one more line in Rakefile

https://github.com/Grejeru/ruby-libvirt/commit/7f9e41d6599ce0e33aa56c42f83c5f58c5c46cd4


Note You need to log in before you can comment on or make changes to this bug.