The kbuild document says that:
ldflags-y... [applies] only to the kbuild makefile in which they are assigned....[is used] for all ld invocations happening during a recursive build.
while
LDFLAGS... [is used] for all invocations of the linker.
I cannot see any difference between them, given a Makefile m (and we type make m)
- suppose
LDFLAGS := x, because it applies for all invocations of the linker, then allldinvoked in any build session starting frommake mhas valuexforLDFLAGS - suppose
ldflags-y := y, becaus if applies for all recursived invocations ofld, then allldinvoked (by any build session starting frommake m) has also valueyforLDFLAGS
Is this interpretation correct?
means that the link flags defined by that variable in a given makefile are used only in rules appearing in the same makefile. They are not inherited from a parent makefile, and they are not transmitted to sub-
makes controlled by other makefiles.This is a statement about the facility in general, not about specific flags designated via any particular use of that facility. It says that you can use an
ldflags-yvariable in any kbuild makefile, and expect to see the behavior described in the docs -- linker invocations in rules appearing directly in the same makefile will use those flags, but they will not automatically be conveyed to sub-makes in other directories.On the other hand, this ...
... appears in the documentation for architecture makefiles. The point of these, as described in the docs, is to define flags appropriate for the overall build and (substantially) everything in it. This variable should be defined only in such a makefile, and the quotation says that the linker flags defined that way are used in all linker runs during the build, no matter in what makefile the corresponding rule appears (including, notably, in directories that are not in the same tree as the architecture makefile).
The docs go on to say that
ldflags-ycan be used for further customization, which you should take to indicate that both are applied in linker runs. Reading a bit more closely between the lines, you should expect the (global)LDFLAGSto appear earlier in the linker command than the (local)ldflags-y.Yes and no. A general kbuild makefile
mshouldn't provide a definition forLDFLAGS. That belongs only in the appropriate architecture makefile. It's unclear what would happen if a kbuild makefile did so anyway, but I suspect that it would cascade to sub-makes.Additionally, you shouldn't attempt to
makea subtree directly if it is configured for kbuild. The system is not designed for that.No. The ability to use an
ldflags-yvariable to provide local link-flag customizations applies to all kbuild makefiles. The specific flags provided that way by a particular makefile do not cascade to sub-makes.