criu/pie/Makefile: simplify and fix
The way criu/pie/Makefile is currently written, ld is run twice:
1. link $(NAME-obj-y) objects to NAME.built-in.o
2. link NAME.built-in.o, pie.lib.a, and compel plugins
to NAME.built-in.bin.o (with compel ldflags and linker script)
There is absolutely no need for such two-stage linking, but it was OK.
It is not OK now, as "compel ldflags" for ARM doesn't need -r, and we
can't run the first stage with -r and the second stage without it.
So, let's simplify linking using a single ld invocation. This is my
third attempt in doing it, I think I nailed it this time -- it is now
clean and (relatively) simple.
While at it:
- fix compel linker script dependency (it was not working);
- rearrange the Makefile so variables goes first, then rules;
- remove a comment about mount implementation in restorer.
NOTE that compel is called with ./ prefix so the file paths it prints
are also prefixed with ./, which is needed for objectify macro to ignore
those.
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-03-24 15:07:42 -07:00
|
|
|
COMPEL_BIN := ./compel/compel-host
|
2016-12-17 03:22:04 -08:00
|
|
|
export COMPEL_BIN
|
|
|
|
|
2016-09-21 23:54:18 +03:00
|
|
|
COMPEL_VERSION_HEADER := compel/include/version.h
|
|
|
|
|
2017-02-22 15:15:45 -08:00
|
|
|
$(COMPEL_VERSION_HEADER): Makefile.versions
|
2016-09-21 23:54:18 +03:00
|
|
|
$(call msg-gen, $(COMPEL_VERSION_HEADER))
|
|
|
|
$(Q) echo "/* Autogenerated, do not edit */" > $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#ifndef COMPEL_SO_VERSION_H__" >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#define COMPEL_SO_VERSION_H__" >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#define COMPEL_SO_VERSION \"$(COMPEL_SO_VERSION)\"" >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#define COMPEL_SO_VERSION_MAJOR " $(COMPEL_SO_VERSION_MAJOR) >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#define COMPEL_SO_VERSION_MINOR " $(COMPEL_SO_VERSION_MINOR) >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#define COMPEL_SO_VERSION_SUBLEVEL " $(COMPEL_SO_VERSION_SUBLEVEL) >> $(COMPEL_VERSION_HEADER)
|
|
|
|
$(Q) echo "#endif /* COMPEL_SO_VERSION_H__ */" >> $(COMPEL_VERSION_HEADER)
|
|
|
|
|
Makefile.compel: simplify compel-deps
Working on CRIU Makefilest feels like walking on a minefield.
This is not an attempt to demine it, but to make some mines
a bit easier to notice.
OK, this is what we're trying to do here:
1. Drop the $(SRC_DIR)/ prefix from the target: as this is a top-level
Makefile, we can just use paths relative to top-level source dir.
2. Drop the $(SRC_DIR) from the symlink, use relative one. Relative
symlinks are always better -- say, if a source directory is
moved, everything will still work.
3. The "compel/include/asm: compel/arch/$(ARCH)/src/lib/include"
dependency is useless. Yes, the left side is created as a symlink
to the right side, but that doesn't mean that "make" should
compare the timestamps of both to decide whether to remake
the target.
4. The "$(COMPEL_VERSION_HEADER): compel/include/asm" dependency
is wrong, the compel/include/asm symlink is not needed for
$(COMPEL_VERSION_HEADER) generation. Remove it.
5. Move compel/plugins/std.built-in.o prerequisite from the rule
to compel-plugins variable, and use it.
travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-17 03:22:08 -08:00
|
|
|
compel/include/asm:
|
2016-10-27 01:15:00 +03:00
|
|
|
$(call msg-gen, $@)
|
Makefile.compel: simplify compel-deps
Working on CRIU Makefilest feels like walking on a minefield.
This is not an attempt to demine it, but to make some mines
a bit easier to notice.
OK, this is what we're trying to do here:
1. Drop the $(SRC_DIR)/ prefix from the target: as this is a top-level
Makefile, we can just use paths relative to top-level source dir.
2. Drop the $(SRC_DIR) from the symlink, use relative one. Relative
symlinks are always better -- say, if a source directory is
moved, everything will still work.
3. The "compel/include/asm: compel/arch/$(ARCH)/src/lib/include"
dependency is useless. Yes, the left side is created as a symlink
to the right side, but that doesn't mean that "make" should
compare the timestamps of both to decide whether to remake
the target.
4. The "$(COMPEL_VERSION_HEADER): compel/include/asm" dependency
is wrong, the compel/include/asm symlink is not needed for
$(COMPEL_VERSION_HEADER) generation. Remove it.
5. Move compel/plugins/std.built-in.o prerequisite from the rule
to compel-plugins variable, and use it.
travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-17 03:22:08 -08:00
|
|
|
$(Q) ln -s ../arch/$(ARCH)/src/lib/include $@
|
2016-10-27 01:15:00 +03:00
|
|
|
|
Makefile.compel: simplify compel-deps
Working on CRIU Makefilest feels like walking on a minefield.
This is not an attempt to demine it, but to make some mines
a bit easier to notice.
OK, this is what we're trying to do here:
1. Drop the $(SRC_DIR)/ prefix from the target: as this is a top-level
Makefile, we can just use paths relative to top-level source dir.
2. Drop the $(SRC_DIR) from the symlink, use relative one. Relative
symlinks are always better -- say, if a source directory is
moved, everything will still work.
3. The "compel/include/asm: compel/arch/$(ARCH)/src/lib/include"
dependency is useless. Yes, the left side is created as a symlink
to the right side, but that doesn't mean that "make" should
compare the timestamps of both to decide whether to remake
the target.
4. The "$(COMPEL_VERSION_HEADER): compel/include/asm" dependency
is wrong, the compel/include/asm symlink is not needed for
$(COMPEL_VERSION_HEADER) generation. Remove it.
5. Move compel/plugins/std.built-in.o prerequisite from the rule
to compel-plugins variable, and use it.
travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-17 03:22:08 -08:00
|
|
|
compel-deps += compel/include/asm
|
2016-10-27 19:01:21 +03:00
|
|
|
compel-deps += $(COMPEL_VERSION_HEADER)
|
|
|
|
compel-deps += $(CONFIG_HEADER)
|
2016-10-19 14:06:56 +03:00
|
|
|
compel-deps += include/common/asm
|
2017-03-24 15:07:45 -07:00
|
|
|
compel-plugins += compel/plugins/std.lib.a compel/plugins/fds.lib.a
|
2016-10-27 19:01:21 +03:00
|
|
|
|
2016-11-25 18:11:54 +03:00
|
|
|
LIBCOMPEL_SO := libcompel.so
|
|
|
|
LIBCOMPEL_A := libcompel.a
|
|
|
|
export LIBCOMPEL_SO LIBCOMPEL_A
|
|
|
|
|
2016-09-21 23:54:18 +03:00
|
|
|
#
|
|
|
|
# Compel itself.
|
2017-02-22 15:15:49 -08:00
|
|
|
compel/Makefile: ;
|
Makefile.compel: simplify compel-deps
Working on CRIU Makefilest feels like walking on a minefield.
This is not an attempt to demine it, but to make some mines
a bit easier to notice.
OK, this is what we're trying to do here:
1. Drop the $(SRC_DIR)/ prefix from the target: as this is a top-level
Makefile, we can just use paths relative to top-level source dir.
2. Drop the $(SRC_DIR) from the symlink, use relative one. Relative
symlinks are always better -- say, if a source directory is
moved, everything will still work.
3. The "compel/include/asm: compel/arch/$(ARCH)/src/lib/include"
dependency is useless. Yes, the left side is created as a symlink
to the right side, but that doesn't mean that "make" should
compare the timestamps of both to decide whether to remake
the target.
4. The "$(COMPEL_VERSION_HEADER): compel/include/asm" dependency
is wrong, the compel/include/asm symlink is not needed for
$(COMPEL_VERSION_HEADER) generation. Remove it.
5. Move compel/plugins/std.built-in.o prerequisite from the rule
to compel-plugins variable, and use it.
travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-17 03:22:08 -08:00
|
|
|
compel/%: $(compel-deps) $(compel-plugins) .FORCE
|
2016-09-21 23:54:18 +03:00
|
|
|
$(Q) $(MAKE) $(build)=compel $@
|
|
|
|
|
2016-12-17 03:22:09 -08:00
|
|
|
criu-deps += compel/compel-host-bin
|
|
|
|
|
2018-07-12 15:51:42 +03:00
|
|
|
#
|
|
|
|
# Make sure the host program is ready after the
|
|
|
|
# library and plugins are built.
|
|
|
|
compel/compel-host-bin: | compel/$(LIBCOMPEL_A) $(compel-plugins)
|
|
|
|
$(COMPEL_BIN): compel/compel-host-bin
|
|
|
|
|
2016-09-21 23:54:18 +03:00
|
|
|
#
|
|
|
|
# Plugins
|
2017-02-22 15:15:49 -08:00
|
|
|
compel/plugins/Makefile: ;
|
2016-10-27 19:01:21 +03:00
|
|
|
compel/plugins/%: $(compel-deps) .FORCE
|
2016-09-21 23:54:18 +03:00
|
|
|
$(Q) $(MAKE) $(build)=compel/plugins $@
|
|
|
|
|
2016-09-26 22:36:34 +03:00
|
|
|
#
|
|
|
|
# GNU make 4.x supports targets matching via wide
|
|
|
|
# match targeting, where GNU make 3.x series (used on
|
|
|
|
# Travis) is not, so we have to write them here explicitly.
|
2017-03-24 15:07:45 -07:00
|
|
|
compel/plugins/std.lib.a: $(compel-deps) .FORCE
|
2016-09-26 22:36:34 +03:00
|
|
|
$(Q) $(MAKE) $(build)=compel/plugins $@
|
|
|
|
|
2017-03-24 15:07:45 -07:00
|
|
|
compel/plugins/shmem.lib.a: $(compel-deps) compel/plugins/std.lib.a .FORCE
|
2017-03-06 21:38:17 +03:00
|
|
|
$(Q) $(MAKE) $(build)=compel/plugins $@
|
|
|
|
|
2017-03-24 15:07:45 -07:00
|
|
|
compel/plugins/fds.lib.a: $(compel-deps) compel/plugins/std.lib.a .FORCE
|
2016-09-26 22:36:34 +03:00
|
|
|
$(Q) $(MAKE) $(build)=compel/plugins $@
|
|
|
|
|
2016-11-25 18:11:54 +03:00
|
|
|
compel/compel: compel/built-in.o compel/$(LIBCOMPEL_A) | $(compel-deps)
|
2016-09-21 23:54:18 +03:00
|
|
|
$(call msg-link, $@)
|
|
|
|
$(Q) $(CC) $(CFLAGS) $^ $(WRAPFLAGS) $(LDFLAGS) -rdynamic -o $@
|
|
|
|
|
|
|
|
#
|
|
|
|
# And compel library.
|
|
|
|
LIBCOMPEL_SO_CFLAGS += $(CFLAGS) -rdynamic -Wl,-soname,$(LIBCOMPEL_SO).$(COMPEL_SO_VERSION_MAJOR)
|
2016-11-25 18:11:54 +03:00
|
|
|
compel/$(LIBCOMPEL_SO): compel/$(LIBCOMPEL_A)
|
2016-09-21 23:54:18 +03:00
|
|
|
$(call msg-link, $@)
|
|
|
|
$(Q) $(CC) -shared $(LIBCOMPEL_SO_CFLAGS) -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(LDFLAGS)
|
2016-11-25 18:11:54 +03:00
|
|
|
|
|
|
|
compel-install-targets += compel/$(LIBCOMPEL_SO)
|
|
|
|
compel-install-targets += compel/compel
|
Makefile.compel: simplify compel-deps
Working on CRIU Makefilest feels like walking on a minefield.
This is not an attempt to demine it, but to make some mines
a bit easier to notice.
OK, this is what we're trying to do here:
1. Drop the $(SRC_DIR)/ prefix from the target: as this is a top-level
Makefile, we can just use paths relative to top-level source dir.
2. Drop the $(SRC_DIR) from the symlink, use relative one. Relative
symlinks are always better -- say, if a source directory is
moved, everything will still work.
3. The "compel/include/asm: compel/arch/$(ARCH)/src/lib/include"
dependency is useless. Yes, the left side is created as a symlink
to the right side, but that doesn't mean that "make" should
compare the timestamps of both to decide whether to remake
the target.
4. The "$(COMPEL_VERSION_HEADER): compel/include/asm" dependency
is wrong, the compel/include/asm symlink is not needed for
$(COMPEL_VERSION_HEADER) generation. Remove it.
5. Move compel/plugins/std.built-in.o prerequisite from the rule
to compel-plugins variable, and use it.
travis-ci: success for More polishing for compel cli
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2016-12-17 03:22:08 -08:00
|
|
|
compel-install-targets += $(compel-plugins)
|