[Python-Dev] -zcombreloc

Andrew Koenig ark@research.att.com
Mon, 23 Sep 2002 09:50:49 -0400 (EDT)

I now believe, after discussion with the binutils developers,
that the problem is that -zcombreloc just plain doesn't
work in any release of binutils.  One implication of this fact
is that turning on -znocombreloc when building python is insufficient
to make it work if you built gcc with -zcombreloc, because that build
will write dynamic libraries that the Sun loader cannot handle no
matter what.

So I think you are right -- the correct fix is to warn people that
they should not use binutils 2.13 on Solaris, period.  I believe that
they will fix the problem in 2.13.1 and will let you know.

Meanwhile, might I suggest including the following test somewhere
in the build procedure?  If it fails, I believe it will not be
possible to build Python successfully, so one might as well find
about it early....

If you run this and the output includes "core dumped', it failed :-)

-------------------------cut here----------------------
#! /bin/sh

mkdir /tmp/t.$$  || exit 3
cd /tmp/t.$$     || exit 3

cat >main.c <<'EOF'
#include <stdio.h>
#include <dlfcn.h>

int main(void)
    void *handle, *sym;
    char *error;

    puts("calling dlopen");
    handle = dlopen("./dyn.so", RTLD_NOW);
    if (!handle) {
        printf("%s\n", dlerror());
	return 1;

    puts("calling dlsym");
    sym = dlsym(handle, "sym");
    if ((error = dlerror()) != 0) {
        printf("%s\n", error);
	return 1;
    puts("calling sym");
    ((void (*)(void))sym)();
    return 0;

cat >dyn.c <<'EOF'
#include <stdio.h>
void sym(void)
    puts("in sym");

[ -n "$SHFLAGS" ] || SHFLAGS="-fPIC -shared"
[ -n "$CC" ]  || CC=gcc

set -x

$CC $CFLAGS $SHFLAGS dyn.c -o dyn.so
$CC $CFLAGS main.c -o main -ldl

./main || exit $?

cd /tmp
rm -rf t.$$