1
1
From: Zeugswetter Andreas <ZeugswetterA@spardat.at>
2
- $Date: 2006/05/26 19:48:32 $
2
+ $Date: 2006/09/20 02:10:11 $
3
3
4
4
On AIX 4.3.2 PostgreSQL compiled with the native IBM compiler xlc
5
5
(vac.C 5.0.1) passes all regression tests. Other versions of OS and
@@ -396,4 +396,81 @@ Replace this with:
396
396
397
397
hosts=local4,bind4
398
398
399
- to deactivate searching for IPv6 addresses.
399
+ to deactivate searching for IPv6 addresses.
400
+
401
+
402
+ Shared Linking
403
+ --------------
404
+
405
+ Shared libraries in AIX are different from shared libraries in Linux.
406
+
407
+ A shared library on AIX is an 'ar' archive containing shared objects. A
408
+ shared object is produced by the linker when invoked appropriately (e.g.
409
+ with -G), it is what we call a shared library on Linux.
410
+
411
+ -> On AIX, you can do a static as well as a dynamic
412
+ -> link against a shared library, it depends on how you
413
+ -> invoke the linker.
414
+
415
+ When you link statically, the shared objects from the library are added
416
+ to your executable as required; when you link dynamically, only
417
+ references to the shared objects are included in the executable.
418
+
419
+ Consequently you do not need a separate static library on AIX if you
420
+ have a dynamic library.
421
+
422
+ However, you CAN have static libraries (ar archives containing *.o
423
+ files), and the linker will link against them. This will of course
424
+ always be a static link.
425
+
426
+ When the AIX linker searches for libraries to link, it will look for a
427
+ library libxy.a as well as for a single shared object libxy.so when you
428
+ tell it to -lyx. When it finds both in the same directory, it will
429
+ prefer libpq.a unless invoked with -brtl.
430
+
431
+ This is where the problem occurs:
432
+
433
+ By default, PostgreSQL will (in the Linux way) create a shared object
434
+ libpq.so and a static library libpq.a in the same directory.
435
+
436
+ Up to now, since the linker was invoked without the -brtl flag, linking
437
+ on AIX was always static, as the linker preferred libpq.a over libpq.so.
438
+
439
+ We could have solved the problem by linking with -brtl on AIX, but we
440
+ chose to go a more AIX-conforming way so that third party programs
441
+ linking against PostgreSQL libraries will not be fooled into linking
442
+ statically by default.
443
+
444
+ The 'new way' on AIX is:
445
+ - Create libxy.so.n as before from the static library
446
+ libxy.a with the linker.
447
+ - Remove libxy.a
448
+ - Recreate libxy.a as a dynamic library with
449
+ ar -cr libxy.a libxy.so.n
450
+ - Only install libxy.a, do not install libxy.so
451
+
452
+ Since linking is dynamic on AIX now, we have a new problem:
453
+
454
+ We must make sure that the executable finds its library even if the
455
+ library is not installed in one of the standard library paths (/usr/lib
456
+ or /lib).
457
+
458
+ On Linux this is done with an RPATH, on AIX the equivalent is LIBPATH
459
+ that can be specified at link time with -blibpath:<colon separated path>
460
+ . If you do not specify the LIBPATH, it is automatically computed from
461
+ the -L arguments given to the linker. The LIBPATH, when set, must
462
+ contain ALL directories where shared libraries should be searched,
463
+ including the standard library directories.
464
+
465
+ Makefile.aix has been changed to link executables with a LIBPATH that
466
+ contains --libdir when PostgreSQL is configured with --enable-rpath (the
467
+ default).
468
+
469
+ The AIX equivalent for the Linux environment variable LD_LIBRARY_PATH is
470
+ LIBPATH.
471
+
472
+ The regression tests rely on LD_LIBRARY_PATH and have to be changed to
473
+ set LIBPATH as well.
474
+
475
+ Laurenz Albe
476
+