crowell / modpagespeed_tmp

Automatically exported from code.google.com/p/modpagespeed
Apache License 2.0
0 stars 0 forks source link

mod_pagespeed 1.3.25.4 fails to compile on OpenSUSE 12.3 #701

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to compile version 1.3.25.4 on OpenSUSE 12.3

What is the expected output? What do you see instead?

The build fails with

[  348s]   CXX(target) 
out/Release/obj.target/instaweb_util/net/instaweb/util/hostname_util.o
[  349s] net/instaweb/util/hostname_util.cc: In function 'GoogleString 
net_instaweb::GetHostname()':
[  349s] net/instaweb/util/hostname_util.cc:48:55: error: 'gethostname' was not 
declared in this scope
[  349s] make: *** 
[out/Release/obj.target/instaweb_util/net/instaweb/util/hostname_util.o] Error 1

What version of the product are you using (please check X-Mod-Pagespeed
header)?

1.3.25.4

On what operating system?

OpenSUSE 12.3 x86_64

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.7/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info 
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada 
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7 
--enable-ssp --disable-libssp --disable-libitm --disable-plugin 
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' 
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib 
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch 
--enable-version-specific-runtime-libs --enable-linker-build-id 
--program-suffix=-4.7 --enable-linux-futex --without-system-libunwind 
--with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (SUSE Linux) 

Original issue reported on code.google.com by robert.munteanu on 18 May 2013 at 8:13

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
I'll try that later on, thanks.

Original comment by robert.munteanu on 20 May 2013 at 2:39

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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