Skip to content

Instantly share code, notes, and snippets.

@RangelReale
Created July 19, 2017 19:33
Show Gist options
  • Save RangelReale/943f0a501d6a3572f3d5aa26cc959bc3 to your computer and use it in GitHub Desktop.
Save RangelReale/943f0a501d6a3572f3d5aa26cc959bc3 to your computer and use it in GitHub Desktop.
Poco SHARED and STATIC build comparison with and without "-static" gcc parameter
## NOTES ##
For some reason the "FileChannelTest.testPurgeAge" and "FileTestEE.testFileAttributes2" tests
always fails on my Ubuntu 16.04 in all builds, I'm not sure why, must be something on
my environment.
==========================================================
SAMPLE: POCO SHARED WITH "-static" gcc parameter (default)
==========================================================
$ git diff
<NOTHING>
$ ./configure --shared --omit=Data/ODBC,Data/MySQL,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page,ApacheConnector,PDF,CppParser,PocoDoc,ProGen,MongoDB,Redis
$ make
$ ldd lib/Linux/i686/libPocoFoundation.so
linux-gate.so.1 => (0xb77f8000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7599000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7594000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb758a000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7413000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb73be000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb73a1000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb71eb000)
/lib/ld-linux.so.2 (0x80089000)
$ ldd Foundation/testsuite/bin/Linux/i686/testrunner
linux-gate.so.1 => (0xb779d000)
libPocoFoundation.so.60 => /home/rangel/Documents/prog/src/poco-shared/lib/Linux/i686/libPocoFoundation.so.60 (0xb7579000)
libPocoCppUnit.so.1 => /home/rangel/Documents/prog/src/poco-shared/lib/Linux/i686/libPocoCppUnit.so.1 (0xb7568000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb752d000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb73b6000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7361000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7344000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb718d000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7188000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb717f000)
/lib/ld-linux.so.2 (0x800d3000)
** run Foundation tests **
$ ./testrunner -all
testPlatform: POCO_OS: 5
POCO_ARCH: 2
testFixedLength:
testBugcheck:
testEnvironment:
OS Name: Linux
OS Display Name: Linux
OS Version: 4.4.0-83-generic
OS Architecture: i686
Node Name: rangel-virtual-machine
Node ID: 00:0c:29:62:ca:3b
Number of CPUs: 1
...
!!!FAILURES!!!
Runs: 723 Failures: 2 Errors: 0
There were 2 failures:
1: N7CppUnit10TestCallerI15FileChannelTestEE.testPurgeAge
"f0.exists()"
in "src/FileChannelTest.cpp", line 364
2: N7CppUnit10TestCallerI8FileTestEE.testFileAttributes2
"tsc - ts >= -2000000 && tsc - ts <= 2000000"
in "src/FileTest.cpp", line 238
==========================================================
SAMPLE: POCO SHARED WITHOUT "-static" gcc parameter
** CONCLUSION:
build exactly the same, no change by the removal of this parameter
the STATICOPT_LINK parameter is not used *at all* on POCO SHARED builds
only the SHAREDOPT_LINK is
==========================================================
$ git diff
diff --git a/build/config/Linux b/build/config/Linux
index 9cc98ed..8bb0057 100644
--- a/build/config/Linux
+++ b/build/config/Linux
@@ -63,7 +63,7 @@ LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
-STATICOPT_LINK = -static
+STATICOPT_LINK =
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK = -Wl,-rpath,$(LIBPATH)
$ ./configure --shared --omit=Data/ODBC,Data/MySQL,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page,ApacheConnector,PDF,CppParser,PocoDoc,ProGen,MongoDB,Redis
$ make
$ ldd lib/Linux/i686/libPocoFoundation.so
linux-gate.so.1 => (0xb77dd000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb757e000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7579000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb756f000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb73f8000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb73a3000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7386000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb71d0000)
/lib/ld-linux.so.2 (0x80041000)
$ ldd Foundation/testsuite/bin/Linux/i686/testrunner
linux-gate.so.1 => (0xb770f000)
libPocoFoundation.so.60 => /home/rangel/Documents/prog/src/poco-shared-nostatic/lib/Linux/i686/libPocoFoundation.so.60 (0xb74eb000)
libPocoCppUnit.so.1 => /home/rangel/Documents/prog/src/poco-shared-nostatic/lib/Linux/i686/libPocoCppUnit.so.1 (0xb74da000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb749f000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7328000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb72d3000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb72b6000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb70ff000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb70fa000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb70f1000)
/lib/ld-linux.so.2 (0x800f9000)
** run Foundation tests **
$ testrunner -all
testPlatform: POCO_OS: 5
POCO_ARCH: 2
testFixedLength:
testBugcheck:
testEnvironment:
OS Name: Linux
OS Display Name: Linux
OS Version: 4.4.0-83-generic
OS Architecture: i686
Node Name: rangel-virtual-machine
Node ID: 00:0c:29:62:ca:3b
Number of CPUs: 1
...
!!!FAILURES!!!
Runs: 723 Failures: 2 Errors: 0
There were 2 failures:
1: N7CppUnit10TestCallerI15FileChannelTestEE.testPurgeAge
"f0.exists()"
in "src/FileChannelTest.cpp", line 364
2: N7CppUnit10TestCallerI8FileTestEE.testFileAttributes2
"tsc - ts >= -2000000 && tsc - ts <= 2000000"
in "src/FileTest.cpp", line 238
==========================================================
SAMPLE: POCO STATIC WITH "-static" gcc parameter (default)
** CONCLUSION:
the test executable wasn't a dynamic executable
the shared library tests fails as expected
the ProcessTest.testSignalExitCode fails
==========================================================
$ git diff
<NOTHING>
$ ./configure --static --omit=Data/ODBC,Data/MySQL,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page,ApacheConnector,PDF,CppParser,PocoDoc,ProGen,MongoDB,Redis
$ make
$ ldd Foundation/testsuite/bin/Linux/i686/static/testrunner
not a dynamic executable
** run Foundation tests **
$ testrunner -all
testPlatform: POCO_OS: 5
POCO_ARCH: 2
testFixedLength:
testBugcheck:
testEnvironment:
OS Name: Linux
OS Display Name: Linux
OS Version: 4.4.0-83-generic
OS Architecture: i686
Node Name: rangel-virtual-machine
Node ID: 00:0c:29:62:ca:3b
Number of CPUs: 1
!!!FAILURES!!!
Runs: 723 Failures: 3 Errors: 5
There were 5 errors:
1: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary1
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
2: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary2
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
3: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary3
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
4: N7CppUnit10TestCallerI15ClassLoaderTestEE.testClassLoader2
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
5: N7CppUnit10TestCallerI15ClassLoaderTestEE.testClassLoader3
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
There were 3 failures:
1: N7CppUnit10TestCallerI15FileChannelTestEE.testPurgeAge
"f0.exists()"
in "src/FileChannelTest.cpp", line 364
2: N7CppUnit10TestCallerI8FileTestEE.testFileAttributes2
"tsc - ts >= -2000000 && tsc - ts <= 2000000"
in "src/FileTest.cpp", line 238
3: N7CppUnit10TestCallerI11ProcessTestEE.testSignalExitCode
"rc == -SIGINT"
in "src/ProcessTest.cpp", line 267
==========================================================
SAMPLE: POCO STATIC WITHOUT "-static" gcc parameter
** CONCLUSION:
the test executable is a dynamic executable exactly like the one on the SHARED build (except for the Poco .so files)
the shared library tests fails as expected
the ProcessTest.testSignalExitCode DOESN'T fail like in the default STATIC build
==========================================================
$ git diff
diff --git a/build/config/Linux b/build/config/Linux
index 9cc98ed..4f36986 100644
--- a/build/config/Linux
+++ b/build/config/Linux
@@ -63,7 +63,7 @@ LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
-STATICOPT_LINK = -static
+STATICOPT_LINK =
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK = -Wl,-rpath,$(LIBPATH)
$ ./configure --static --omit=Data/ODBC,Data/MySQL,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page,ApacheConnector,PDF,CppParser,PocoDoc,ProGen,MongoDB,Redis
$ make
$ ldd Foundation/testsuite/bin/Linux/i686/static/testrunner
linux-gate.so.1 => (0xb770c000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb76cc000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb76c7000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb76bd000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb7546000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb74f1000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb74d4000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb731e000)
/lib/ld-linux.so.2 (0x8002c000)
** run Foundation tests **
$ testrunner -all
testPlatform: POCO_OS: 5
POCO_ARCH: 2
testFixedLength:
testBugcheck:
testEnvironment:
OS Name: Linux
OS Display Name: Linux
OS Version: 4.4.0-83-generic
OS Architecture: i686
Node Name: rangel-virtual-machine
Node ID: 00:0c:29:62:ca:3b
Number of CPUs: 1
...
!!!FAILURES!!!
Runs: 723 Failures: 2 Errors: 5
There were 5 errors:
1: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary1
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
2: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary2
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
3: N7CppUnit10TestCallerI17SharedLibraryTestEE.testSharedLibrary3
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
4: N7CppUnit10TestCallerI15ClassLoaderTestEE.testClassLoader2
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
5: N7CppUnit10TestCallerI15ClassLoaderTestEE.testClassLoader3
"N4Poco20LibraryLoadExceptionE: Cannot load library"
in "<unknown>", line -1
There were 2 failures:
1: N7CppUnit10TestCallerI15FileChannelTestEE.testPurgeAge
"f0.exists()"
in "src/FileChannelTest.cpp", line 364
2: N7CppUnit10TestCallerI8FileTestEE.testFileAttributes2
"tsc - ts >= -2000000 && tsc - ts <= 2000000"
in "src/FileTest.cpp", line 238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment