Closed GoogleCodeExporter closed 9 years ago
Hi Robert,
Sorry about that :(
Could you do a couple of checks on OpenSUSE for me please?
1. man gethostname - does it exist on OpenSUSE?
2. If so, what #include does it say to use in the man page?
3. man -s 2 uname - does it exist on OpenSUSE?
4. If so, what #include does it say to use in the man page?
I think I'll have to change hostname_util.cc to use uname(2) on Linux since
that's how gethostname() is implemented anyway.
Thanks! m.
Original comment by matterb...@google.com
on 20 May 2013 at 1:47
glibc has had gethostname since forever, but it needs some #define's for it.
_BSD_SOURCE || _XOPEN_SOURCE >= 500
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200112L
... which is pretty annoying.
Original comment by morlov...@google.com
on 20 May 2013 at 1:51
Hi,
About your questions
1. man gethostname - exists
2. The include is #include <unistd.h>
3. man -s 2 uname - exists
4. The include is #include <sys/utsname.h>
Thanks!
Robert
Original comment by robert.munteanu
on 20 May 2013 at 2:06
Thanks. I expect Maks's point is right - the symbol is in unistd.h but it's not
exposed because we don't have the right #defines.
I think that switching to uname(2) will work on all currently supported OS's so
I'll get started on that.
In the meantime I expect you can work around this by adding the requisite
#define just before the #include <unistd.h> in hostname_util.cc.
It should be:
#define _BSD_SOURCE
#include <unistd.h>
Thanks, m.
Original comment by matterb...@google.com
on 20 May 2013 at 2:13
I'll try that later on, thanks.
Original comment by robert.munteanu
on 20 May 2013 at 2:39
Hm, I'm having problems making it work. I did not find any #include <unistd.h>
in hostname_util.cc so I applied the following diff
--- net/instaweb/util/hostname_util.cc.orig 2013-05-20 22:52:35.163273452 +0300
+++ net/instaweb/util/hostname_util.cc 2013-05-20 22:52:23.755216638 +0300
@@ -16,6 +16,7 @@
// Author: matterbury@google.com (Matt Atterbury)
+#define _BSD_SOURCE
#include "net/instaweb/util/public/hostname_util.h"
#include <limits.h>
Compilation still fails with this diff applied
[ 288s] CXX(target)
out/Release/obj.target/instaweb_util/net/instaweb/util/hostname_util.o
[ 288s] net/instaweb/util/hostname_util.cc: In function 'GoogleString
net_instaweb::GetHostname()':
[ 288s] net/instaweb/util/hostname_util.cc:49:55: error: 'gethostname' was not
declared in this scope
[ 288s] make: ***
[out/Release/obj.target/instaweb_util/net/instaweb/util/hostname_util.o] Error
1
What am I doing wrong?
Thanks,
Robert
Original comment by robert.munteanu
on 20 May 2013 at 8:09
Doh! I didn't notice you're compiling an older version of the file, sorry:
Change the #elif on L34 to a #if.
Add another #endif after the one on line 36.
You should see #if defined(WIN32) on line 27 and on line 31 a comment starting
with:
// MacOS does not ...
Before this comment line insert these lines:
#else
// Some Linux environments require this, although not all, but it's benign.
#if defined(unix)
#define _BSD_SOURCE
#include <unistd.h>
#endif // unix
Let me know how it goes, thanks! m.
Original comment by matterb...@google.com
on 20 May 2013 at 8:16
I really must have sloppy fingers :-) Following your instructions I always get
errors about my #if #endif clauses, so here's my original file -
http://pastebin.com/CBkniLTK . Can you upload/paste a 'fixed' fragment?
Also, FYI, I also get 'net/instaweb/util/hostname_util.cc:32:0: warning:
"_BSD_SOURCE" redefined [enabled by default]' , but that's something to look
into later.
Original comment by robert.munteanu
on 20 May 2013 at 9:02
I expect my instructions were faulty. See http://pastebin.com/mdCdAYKK
However, given the warning message about _BSD_SOURCE I expect this won't make
any difference :-(
Original comment by matterb...@google.com
on 21 May 2013 at 12:46
Good news. The snippet you pasted worked for me. I still got the _BSD_SOURCE
warning, but after removing it the code compiles without warnings.
Thanks for the help, it's much appreciated. I can now submit an updated RPM to
the OpenSUSE repository.
Robert
Original comment by robert.munteanu
on 21 May 2013 at 2:38
I believe this problem has already been fixed in later versions of
mod_pagespeed (the beta version is up to 1.5.27) so I am going to close this
bug without change.
Robert, if you get another problem with the next stable release either reopen
this one or create a new bug, thanks!
Original comment by matterb...@google.com
on 24 May 2013 at 12:19
And thanks for doing this Robert -- ping us when you get the version uploaded &
we can send the announcement to mod-pagespeed-announce.
Original comment by jmara...@google.com
on 24 May 2013 at 12:29
The new version is available at
http://software.opensuse.org/package/apache2-mod_pagespeed .
Thanks again.
Original comment by robert.munteanu
on 24 May 2013 at 12:36
Original issue reported on code.google.com by
robert.munteanu
on 18 May 2013 at 8:13