This change aligns the build with the FreeBSD traditional approach to track inter-dependencies.
I only converted libs, binaries will follow if this approach if found sensible.
Also, I do not understand the __L stuff, please provide the pointers.
Differential D15648
Rework ofed build. kib on Jun 1 2018, 9:35 PM. Authored by Tags None Referenced Files
Subscribers
Details
This change aligns the build with the FreeBSD traditional approach to track inter-dependencies. I only converted libs, binaries will follow if this approach if found sensible. Also, I do not understand the __L stuff, please provide the pointers.
Diff Detail
Event Timeline
Comment Actions Import suggested handling of libraries dependencies. Only binaries left to handle. Comment Actions Abusing prebuild_libs seems like a hack! Add a five step library build with accompanying variables. That will make the Makefile code more clean and easier to understand instead of all these manual dependencies. Comment Actions Sort of, yes. I agree with the statement that ib libs should be not put into the prebuild libs. For now I used the recipe provided by bdrewery. When the build system grows the ability to handle this case cleaner, we will adopt. Comment Actions Complete patch, no components (even include) are built in contrib, everything is moved to lib/ofed and usr.bin/ofed. Patch requires some more quality checks, I only build world for amd64. I plan to do make universe with and without ofed for it, and installation checks on amd64. I think that for the purpose of enabling ofed by default, the list of the binaries should be examined and trimmed. The useless binaries should be put under some build knob, like WITH_OFED_EXTRAS, default to off. This is for later. Comment Actions When running make tinderbox to check the build, I noted that sporadically mips and powerpc buildworlds fail with the nm: elf_begin: Invalid argument error. This comes from the nm invocation in the sorting subcommand for linking dso. The errors are random and seem to occur only for gcc-built arches. Reading of the nm and libelf source code suggested that the most likely cause is the invalid ELF structure of the .pico file is damaged. So I applied the following debugging patch to see what is going on: diff --git a/contrib/elftoolchain/nm/nm.c b/contrib/elftoolchain/nm/nm.c index 33ab44295c7..70ceeb5e05e 100644 --- a/contrib/elftoolchain/nm/nm.c +++ b/contrib/elftoolchain/nm/nm.c @@ -1467,7 +1467,7 @@ read_object(const char *filename) assert(filename != NULL && "filename is null"); - if ((fd = open(filename, O_RDONLY)) == -1) { + if ((fd = open(filename, O_RDONLY | O_EXLOCK | O_SHLOCK)) == -1) { warn("'%s'", filename); return (1); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 09f665e8f3f..b6700c6eeb8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -348,6 +348,13 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, if ((error = VOP_OPEN(vp, fmode, cred, td, fp)) != 0) return (error); + if ((fmode & (O_EXLOCK | O_SHLOCK)) == (O_EXLOCK | O_SHLOCK) && + (fmode & FWRITE) == 0 && vp->v_writecount > 0) { + error = EDOOFUS; + goto exx; + } + + while ((fmode & (O_EXLOCK | O_SHLOCK)) != 0) { KASSERT(fp != NULL, ("open with flock requires fp")); if (fp->f_type != DTYPE_NONE && fp->f_type != DTYPE_VNODE) { @@ -387,7 +394,7 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, error = vn_writechk(vp); break; } - +exx: if (error != 0) { fp->f_flag |= FOPENFAILED; fp->f_vnode = vp; What the patch does is it makes nm(1) to pass very specific combination of flags to the kernel code for open(2). When kernel detects read-only open of the file with that combination of flags, it checks the count of writers to the underlying vnode (v_writecount). If there is a writer, the open(2) syscall fails with EDOOFUS. And indeed, I got the error --- libibnetdisc.so.5.full --- building shared library libibnetdisc.so.5 c++ -isystem /da/1/obj/da/1/src/powerpc.powerpc64/tmp/usr/include -L/da/1/obj/da/1/src/powerpc.powerpc64/tmp/usr/lib -B/da/1/obj/da/1/src/powerpc.powerpc64/tmp/usr/lib --sysroot=/da/1/obj/da/1/srcpowerpc.powerpc64/tmp -B/da/1/obj/da/1/src/powerpc.powerpc64/tmp/usr/bin -Wl,--version-script=/da/1/src/contrib/ofed/libibnetdisc/libibnetdisc.map -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel -o libibnetdisc.so.5.full -Wl,-soname,libibnetdisc.so.5 `NM='nm' NMFLAGS='' lorder chassis.pico g_hash_table.pico ibnetdisc.pico ibnetdisc_cache.pico query_smp.pico | tsort -q` -L/da/1/obj/da/1/src/powerpc.powerpc64/lib/ofed/libibmad -L/da/1/obj/da/1/src/powerpc.powerpc64/lib/ofed/libibumad -L/da/1/obj/da/1/src/powerpc.powerpc64/lib/ofed/complib -losmcomp -libmad -libumad nm: 'query_smp.pico': Programming error So it seems that linking command was started before the compiling stage finished, there was still some process writing to a .pico file. I do not see anything unusual in my Makefiles for libraries. Is it a race in the build system ? In make ?
Comment Actions "prebuild libs" are really just a list of libraries that other libraries or directories with many libraries in them (like lib/ or ofed/lib) depend on. It is a hack in the sense that someone didn't want to write out the whole dependency graph for everything in lib/ on lib/libthr for example. By just moving libthr to the "prebuild libs" phase then all of lib/ can be built later in "generic" without explicit dependencies. The same applies here so we can just build "ofed/lib" in generic libs phase without writing out a whole large dependency list (like ofed/lib/Makefile's SUBDIR_DEPEND plus all of the LIBADDS for each library for a true dependency graph). We get a simpler 2 or 3 __L lines rather than 15. Comment Actions Consider it Reviewed after these are fixed.
Comment Actions Tinderbox and installworld tests passed with WITH_OFED=yes. I think that the patch is ready to go. Comment Actions I obviously never ever build this patch without -j. All the testing was done with make -j 32 on 8x2x2 skylake xeon. |