Commit 024cc109 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by mdavidsaver

build_dso: Fix incremental rebuild

The code was trying to create solibbase symlink pointing to -> outbaselib, e.g.

    libdemo.so.1.0 -> build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0

However if the source file in worktree already exists, symlinking was
failing with an error. Fix it by making sure that source file does not
exist before calling os.symlink.

Also there was related thinko in log.ingf describing who points to
who/where, which is corrected along the way.

Without the fix newly added test fails as

    ...
    running build_dso
    Building DSOs
    building 'dsodemo.lib.demo' DSO as build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0
    creating build
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DBUILD_FOO -c foo.c -o build/temp.linux-x86_64-2.7/foo.o -DALL -DISC
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DBUILD_FOO -c bar.cpp -o build/temp.linux-x86_64-2.7/bar.o -DALL -DISCXX
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/dsodemo
    creating build/lib.linux-x86_64-2.7/dsodemo/lib
    x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/foo.o build/temp.linux-x86_64-2.7/bar.o -o build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0 -Wl,-h,libdemo.so.1.0
    symlink libdemo.so.1.0 -> build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0
    creating dsodemo/lib
    copying build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0 -> dsodemo/lib
    copying build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so -> dsodemo/lib
    running build_dso
    Building DSOs
    building 'dsodemo.lib.demo' DSO as build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DBUILD_FOO -c foo.c -o build/temp.linux-x86_64-2.7/foo.o -DALL -DISC
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DBUILD_FOO -c bar.cpp -o build/temp.linux-x86_64-2.7/bar.o -DALL -DISCXX
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/foo.o build/temp.linux-x86_64-2.7/bar.o -o build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0 -Wl,-h,libdemo.so.1.0
    symlink libdemo.so.1.0 -> build/lib.linux-x86_64-2.7/dsodemo/lib/libdemo.so.1.0
    error: [Errno 17] File exists
parent a3c37836
...@@ -325,8 +325,10 @@ class build_dso(dso2libmixin, Command): ...@@ -325,8 +325,10 @@ class build_dso(dso2libmixin, Command):
if baselib!=solib: if baselib!=solib:
# we make best effort here, even though zipfiles (.whl or .egg) will contain copies # we make best effort here, even though zipfiles (.whl or .egg) will contain copies
log.info("symlink %s -> %s", solibbase, outlib) log.info("symlink %s <- %s", solibbase, outbaselib)
if not self.dry_run: if not self.dry_run:
if os.path.exists(outbaselib):
os.unlink(outbaselib)
os.symlink(solibbase, outbaselib) os.symlink(solibbase, outbaselib)
#self.copy_file(outlib, outbaselib) # link="sym" seem to get the target path wrong #self.copy_file(outlib, outbaselib) # link="sym" seem to get the target path wrong
......
...@@ -27,6 +27,7 @@ cd example ...@@ -27,6 +27,7 @@ cd example
git clean -fdx # `setup.py clean` does not clean inplace built files git clean -fdx # `setup.py clean` does not clean inplace built files
"$PYTHON" -m dsodemo.cli 2>/dev/null && die "error: worktree must be clean" "$PYTHON" -m dsodemo.cli 2>/dev/null && die "error: worktree must be clean"
"$PYTHON" setup.py -v build_dso -i "$PYTHON" setup.py -v build_dso -i
"$PYTHON" setup.py -v build_dso -i -f # incremental recompile
"$PYTHON" setup.py -v build_ext -i "$PYTHON" setup.py -v build_ext -i
"$PYTHON" -m dsodemo.cli "$PYTHON" -m dsodemo.cli
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment