infinity0 / mozilla-gnome-keyring-legacy

A firefox extension that enables Gnome Keyring integration (legacy version)
https://bugzilla.mozilla.org/show_bug.cgi?id=309807
Other
55 stars 8 forks source link

Failure to build with firefox 27 #42

Closed MeisterP closed 10 years ago

MeisterP commented 10 years ago
make -j9 -l8 VERSION=0.6.9 'XUL_CFLAGS=-I/usr/include/firefox -I/usr/include/nspr' 'XUL_LDFLAGS=-L/usr/lib64/firefox -L/usr/lib64/firefox/sdk/lib       -lxpcomglue_s -lxul -lmozalloc -lmozsqlite3 -lplds4 -lplc4      -lnspr4 -lpthread -ldl' XPCOM_ABI_FLAGS=-Wl,-rpath=/usr/lib64/firefox 
CXX="g++" XUL_CFLAGS="-I/usr/include/firefox -I/usr/include/nspr" XUL_LDFLAGS="-L/usr/lib64/firefox -L/usr/lib64/firefox/sdk/lib        -lxpcomglue_s -lxul -lmozalloc -lmozsqlite3 -lplds4 -lplc4      -lnspr4 -lpthread -ldl" XPCOM_ABI_FLAGS="-Wl,-rpath=/usr/lib64/firefox" GNOME_CFLAGS="`pkg-config --cflags gnome-keyring-1`" GNOME_LDFLAGS="`pkg-config --libs gnome-keyring-1`" CXXFLAGS="-march=native -O2 -pipe -Wall -fno-rtti -fno-exceptions -fPIC -std=gnu++0x -D__STDC_LIMIT_MACROS" LDFLAGS="-Wl,-O1 -Wl,--as-needed " sh config.sh GnomeKeyring.h xpcom_abi.cpp Makefile > config.vars
In file included from /usr/include/firefox/nsStringAPI.h:19:0,
                 from xpcom_abi.cpp:6:
/usr/include/firefox/mozilla/Char16.h:68:18: error: conflicting declaration ‘typedef char16_t PRUnichar’
 typedef char16_t PRUnichar;
                  ^
In file included from /usr/include/nspr/prthread.h:46:0,
                 from /usr/include/firefox/nsISupportsImpl.h:25,
                 from /usr/include/firefox/nsISupportsUtils.h:26,
                 from /usr/include/firefox/nsISupports.h:123,
                 from /usr/include/firefox/nsIXULRuntime.h:10,
                 from xpcom_abi.cpp:4:
/usr/include/nspr/prtypes.h:490:18: error: ‘PRUnichar’ has a previous declaration as ‘typedef PRUint16 PRUnichar’
 typedef PRUint16 PRUnichar;
                  ^
make: *** [config.vars] Error 1

Probably relevant: https://groups.google.com/forum/#!msg/selenium-developers/vl7nRW6_BNM/Z9bF0dWFoKgJ https://bugzilla.mozilla.org/show_bug.cgi?id=927728

MeisterP commented 10 years ago

The fix should be to include mozilla/Char16.h although I still didn't manage to compile the extension. see https://bugzilla.mozilla.org/show_bug.cgi?id=951984#c7

infinity0 commented 10 years ago

Hey, no actually the fix is to replace PRUnichar with char16_t in the code of this extension, which you can do easily as the end-user. But I, as the package maintainer, will need to do a compile-time check for XUL version >= 27 which makes things more complex.

infinity0 commented 10 years ago

correction: what I wrote above applies for the bug you linked.

What you seem to be experiencing is inconsistent headers. I'm not sure why your system got to that stage in the first place, but try upgrading all your headers packages to their latest versions.

MeisterP commented 10 years ago

What you seem to be experiencing is inconsistent headers. I'm not sure why your system got to that stage in the first place, but try upgrading all your headers packages to their latest versions.

Inconsistent headers indeed. I think it's an upstream issue.

This is what mozilla is currently doing: https://hg.mozilla.org/mozilla-central/rev/30d9e30f0c8c#l8.12

Force-include Char16.h in order to define PRUnichar as char16_t everywhere.
Note that this should be the first #include to make sure that prtypes.h does
not attempt to define PRUnichar.

It should be fixed in future versions though: https://bugzilla.mozilla.org/show_bug.cgi?id=956507

smithfred commented 10 years ago

What's the best way to deal with this as an end user of your extension? Does this depend on Mozilla patching their code, or is there a workaround that can be implemented on the extension side?

Greatly appreciate your continued work keeping this extension up to date by the way!

infinity0 commented 10 years ago

@smithfred it depends on which bug you are hit with, 927728 or 956507. for the former, do the replacement as I said above. For the latter you can trying playing with inserting #undef PRUniChar between where the two conflicting defs get included, in GnomeKeyring.c. (Not guaranteed though, I don't have time right now to play with it myself.) If you get it working, please send in a patch!

smithfred commented 10 years ago

I don't know C++, but seems you can't #undef a #typedef?

The relevant includes are prtypes.h via GnomeKeyring.h, and Char16.h via nsStringAPI.h. I tried working around instead using either #define PRUnichar SomethingElse after #include "GnomeKeyring.h", or #define PRUnichar SomethingElse before, and #define PRUnichar PRUnichar after - this takes care of the first error but it still doesn't build.

In case it's not obvious, I really have no idea what I'm doing :) So I'll just give you the 2 outputs if that's enlightening. In either case, there seem to be other unrelated errors? I'm trying to build against libgnome-keyring-devel-3.8.0-1.fc19 and xulrunner-devel-27.0-1.fc19 by the way.

Output before changes:

. ./config.vars; \
make -f Makefile mozilla-gnome-keyring-dev-1392297576.xpi
make[1]: Entering directory `mozilla-gnome-keyring-master'
g++ GnomeKeyring.cpp -o libgnomekeyring.so -shared -DHAVE_NSILMS_GETISLOGGEDIN= \
    `pkg-config --cflags libxul` `pkg-config --libs libxul` `pkg-config --cflags gnome-keyring-1` `pkg-config --libs gnome-keyring-1` -Wall -fno-rtti -fno-exceptions -fPIC -std=gnu++0x -D__STDC_LIMIT_MACROS 
GnomeKeyring.cpp:876:30: error: #if with no expression
 #if HAVE_NSILMS_GETISLOGGEDIN
                              ^
In file included from /usr/include/xulrunner-27.0/nsStringAPI.h:19:0,
                 from GnomeKeyring.cpp:46:
/usr/include/xulrunner-27.0/mozilla/Char16.h:68:18: error: conflicting declaration ‘typedef char16_t PRUnichar’
 typedef char16_t PRUnichar;
                  ^
In file included from /usr/include/nspr4/prthread.h:46:0,
                 from /usr/include/xulrunner-27.0/nsISupportsImpl.h:25,
                 from /usr/include/xulrunner-27.0/nsISupportsUtils.h:26,
                 from /usr/include/xulrunner-27.0/nsISupports.h:123,
                 from /usr/include/xulrunner-27.0/nsILoginManagerStorage.h:10,
                 from GnomeKeyring.h:40,
                 from GnomeKeyring.cpp:40:
/usr/include/nspr4/prtypes.h:490:18: error: ‘PRUnichar’ has a previous declaration as ‘typedef PRUint16 PRUnichar’
 typedef PRUint16 PRUnichar;
                  ^
In file included from /usr/include/sched.h:29:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/glib-2.0/glib/deprecated/gthread.h:123,
                 from /usr/include/glib-2.0/glib.h:109,
                 from /usr/include/gnome-keyring-1/gnome-keyring.h:27,
                 from GnomeKeyring.h:42,
                 from GnomeKeyring.cpp:40:
/usr/include/xulrunner-27.0/jspubtd.h:408:74: warning: invalid access to non-static data member ‘js::PerThreadDataFriendFields::RuntimeDummy::mainThread’  of NULL object [-Winvalid-offsetof]
     static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread);
                                                                          ^
/usr/include/xulrunner-27.0/jspubtd.h:408:74: warning: (perhaps the ‘offsetof’ macro was used incorrectly) [-Winvalid-offsetof]
In file included from /usr/include/xulrunner-27.0/nsISupportsUtils.h:26:0,
                 from /usr/include/xulrunner-27.0/nsISupports.h:123,
                 from /usr/include/xulrunner-27.0/nsILoginManagerStorage.h:10,
                 from GnomeKeyring.h:40,
                 from GnomeKeyring.cpp:40:
GnomeKeyring.cpp: In member function ‘virtual nsrefcnt GnomeKeyring::Release()’:
/usr/include/xulrunner-27.0/nsISupportsImpl.h:494:52: warning: deleting object of polymorphic class type ‘GnomeKeyring’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
   NS_IMPL_RELEASE_WITH_DESTROY(_class, delete (this))
                                                    ^
/usr/include/xulrunner-27.0/nsISupportsImpl.h:474:5: note: in definition of macro ‘NS_IMPL_RELEASE_WITH_DESTROY’
     _destroy;                                                                 \
     ^
GnomeKeyring.cpp:560:1: note: in expansion of macro ‘NS_IMPL_RELEASE’
 NS_IMPL_RELEASE(GnomeKeyring)
 ^
GnomeKeyring.cpp: At global scope:
GnomeKeyring.cpp:617:15: error: prototype for ‘nsresult GnomeKeyring::InitWithFile(nsIFile*, nsIFile*)’ does not match any in class ‘GnomeKeyring’
 NS_IMETHODIMP GnomeKeyring::InitWithFile(nsIFile *aInputFile,
               ^
In file included from GnomeKeyring.h:40:0,
                 from GnomeKeyring.cpp:40:
/usr/include/xulrunner-27.0/nsILoginManagerStorage.h:91:14: error: candidate is: virtual nsresult GnomeKeyring::InitWithFile(nsIFile*)
   NS_IMETHOD InitWithFile(nsIFile *aFile); \
              ^
GnomeKeyring.h:89:3: note: in expansion of macro ‘NS_DECL_NSILOGINMANAGERSTORAGE’
   NS_DECL_NSILOGINMANAGERSTORAGE
   ^
make[1]: *** [libgnomekeyring.so] Error 1
make[1]: Leaving directory `mozilla-gnome-keyring-master'
make: *** [build-xpi] Error 2

Output after changes:

. ./config.vars; \
make -f Makefile mozilla-gnome-keyring-dev-1392297553.xpi
make[1]: Entering directory `mozilla-gnome-keyring-master'
g++ GnomeKeyring.cpp -o libgnomekeyring.so -shared -DHAVE_NSILMS_GETISLOGGEDIN= \
    `pkg-config --cflags libxul` `pkg-config --libs libxul` `pkg-config --cflags gnome-keyring-1` `pkg-config --libs gnome-keyring-1` -Wall -fno-rtti -fno-exceptions -fPIC -std=gnu++0x -D__STDC_LIMIT_MACROS 
GnomeKeyring.cpp:877:30: error: #if with no expression
 #if HAVE_NSILMS_GETISLOGGEDIN
                              ^
In file included from /usr/include/sched.h:29:0,
                 from /usr/include/pthread.h:23,
                 from /usr/include/glib-2.0/glib/deprecated/gthread.h:123,
                 from /usr/include/glib-2.0/glib.h:109,
                 from /usr/include/gnome-keyring-1/gnome-keyring.h:27,
                 from GnomeKeyring.h:42,
                 from GnomeKeyring.cpp:39:
/usr/include/xulrunner-27.0/jspubtd.h:408:74: warning: invalid access to non-static data member ‘js::PerThreadDataFriendFields::RuntimeDummy::mainThread’  of NULL object [-Winvalid-offsetof]
     static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread);
                                                                          ^
/usr/include/xulrunner-27.0/jspubtd.h:408:74: warning: (perhaps the ‘offsetof’ macro was used incorrectly) [-Winvalid-offsetof]
In file included from /usr/include/xulrunner-27.0/nsISupportsUtils.h:26:0,
                 from /usr/include/xulrunner-27.0/nsISupports.h:123,
                 from /usr/include/xulrunner-27.0/nsILoginManagerStorage.h:10,
                 from GnomeKeyring.h:40,
                 from GnomeKeyring.cpp:39:
GnomeKeyring.cpp: In member function ‘virtual nsrefcnt GnomeKeyring::Release()’:
/usr/include/xulrunner-27.0/nsISupportsImpl.h:494:52: warning: deleting object of polymorphic class type ‘GnomeKeyring’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
   NS_IMPL_RELEASE_WITH_DESTROY(_class, delete (this))
                                                    ^
/usr/include/xulrunner-27.0/nsISupportsImpl.h:474:5: note: in definition of macro ‘NS_IMPL_RELEASE_WITH_DESTROY’
     _destroy;                                                                 \
     ^
GnomeKeyring.cpp:561:1: note: in expansion of macro ‘NS_IMPL_RELEASE’
 NS_IMPL_RELEASE(GnomeKeyring)
 ^
GnomeKeyring.cpp: At global scope:
GnomeKeyring.cpp:618:15: error: prototype for ‘nsresult GnomeKeyring::InitWithFile(nsIFile*, nsIFile*)’ does not match any in class ‘GnomeKeyring’
 NS_IMETHODIMP GnomeKeyring::InitWithFile(nsIFile *aInputFile,
               ^
In file included from GnomeKeyring.h:40:0,
                 from GnomeKeyring.cpp:39:
/usr/include/xulrunner-27.0/nsILoginManagerStorage.h:91:14: error: candidate is: virtual nsresult GnomeKeyring::InitWithFile(nsIFile*)
   NS_IMETHOD InitWithFile(nsIFile *aFile); \
              ^
GnomeKeyring.h:89:3: note: in expansion of macro ‘NS_DECL_NSILOGINMANAGERSTORAGE’
   NS_DECL_NSILOGINMANAGERSTORAGE
   ^
GnomeKeyring.cpp:777:15: error: prototype for ‘nsresult GnomeKeyring::GetAllDisabledHosts(PRUint32*, GKPRUnichar***)’ does not match any in class ‘GnomeKeyring’
 NS_IMETHODIMP GnomeKeyring::GetAllDisabledHosts(PRUint32 *aCount,
               ^
In file included from GnomeKeyring.h:40:0,
                 from GnomeKeyring.cpp:39:
/usr/include/xulrunner-27.0/nsILoginManagerStorage.h:99:14: error: candidate is: virtual nsresult GnomeKeyring::GetAllDisabledHosts(uint32_t*, PRUnichar***)
   NS_IMETHOD GetAllDisabledHosts(uint32_t *count, PRUnichar * **hostnames); \
              ^
GnomeKeyring.h:89:3: note: in expansion of macro ‘NS_DECL_NSILOGINMANAGERSTORAGE’
   NS_DECL_NSILOGINMANAGERSTORAGE
   ^
make[1]: *** [libgnomekeyring.so] Error 1
make[1]: Leaving directory `mozilla-gnome-keyring-master'
make: *** [build-xpi] Error 2
smithfred commented 10 years ago

The above output is from a 2nd iteration of make by the way; the first one produces an error the same as the first post in this bug, which I tried working around as follows in xpcom_abi.cpp:

#define PRUnichar PRUnichar2
#include "nsIXULRuntime.h"
#define PRUnichar PRUnichar

I've always used make || make to build this extension incidentally; the first make always results in make[1]: *** No rule to make target 'mozilla-gnome-keyring-dev-1392299973.xpi'. Stop.

ghost commented 10 years ago

I was able to compile the extension following the hint of including 'Char16.h' first in the 'GnomeKeyring.cpp' and the 'xpcom_abi.cpp'.

Then i modified the 'GnomeKeyring.cpp' in replacing

NS_IMETHODIMP GnomeKeyring::InitWithFile(nsIFile *aInputFile,
                                         nsIFile *aOutputFile)
{
  // TODO
  return Init();
}

with

NS_IMETHODIMP GnomeKeyring::InitWithFile(nsIFile *aFile)
{
  // TODO
  return Init();
}

edit: i dont know if i was using the latest version. The file i compiled is mozilla-gnome-keyring-0.6.6-8-g89651d8. Nevertheless it works with Firefox 27.0 under Ubuntu Gnome 13.10

smithfred commented 10 years ago

Thanks MeisterP, worked for me. Specifically for the Char16.h step I put

#include "/usr/include/xulrunner-27.0/mozilla/Char16.h"

at the top of the includes in GnomeKeyring.cpp and before #include "nsIXULRuntime.h" in xpcom_abi.cpp.

alci63 commented 10 years ago

Hi, I had the same problems with FF28, and could work it around the same way :

With these modifications, I could build the extension and make it work with FF28 (under Ubuntu Trusty, for that matters)

Thanks all for the tips, and thank to Infinity0 for maintening the extension !

infinity0 commented 10 years ago

Hey everyone, I am glad a solution has been found. Apologies I haven't gotten around to fixing this yet. As I said earlier the main difficulty for me as the maintainer, is to have the same code work for both ff27/28 and earlier versions. I am happy to accept a pull request. Or you guys can review/contribute to swick's javascript reimplementation of this extension, over at ticket #43. I definitely want to switch to it at some point. This continual ABI breakage crap is BS.

infinity0 commented 10 years ago

Just push a commit b637542 to fix this, please let me know if it works (i.e. out-of-the-box make clean-all all) for you guys!

infinity0 commented 10 years ago

No response for a week; closing.