@@ -338,7 +338,7 @@ endif
# BTRFS_SEPARATED_BUILD), using "cfile" from sc_map (cmd-xxx.c) as gcc infile.
btrfs-%.separated.o: $(call sc_get,$(@:%.separated.o=%),cfile)
@echo " [CC] $@"
- $(Q)$(CC) $(CFLAGS) \
+ $(Q)$(CC) $(CFLAGS) -Wno-unused-function -Wno-unused-const-variable \
-DBTRFS_SEPARATED_BUILD \
-DBTRFS_SEPARATED_ENTRY=$(call sc_get,$(@:%.separated.o=%),entry) \
-DBTRFS_SEPARATED_USAGE=$(call sc_get,$(@:%.separated.o=%),entry)_usage \
@@ -914,6 +914,7 @@ static int cmd_balance_full(int argc, char **argv)
static const char balance_cmd_group_info[] =
"balance data across devices, or change block groups using filters";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group balance_cmd_group = {
balance_cmd_group_usage, balance_cmd_group_info, {
{ "start", cmd_balance_start, cmd_balance_start_usage, NULL, 0 },
@@ -940,3 +941,4 @@ int cmd_balance(int argc, char **argv)
return handle_command_group(&balance_cmd_group, argc, argv);
}
+#endif
@@ -597,6 +597,7 @@ static int cmd_device_usage(int argc, char **argv)
static const char device_cmd_group_info[] =
"manage and query devices in the filesystem";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group device_cmd_group = {
device_cmd_group_usage, device_cmd_group_info, {
{ "add", cmd_device_add, cmd_device_add_usage, NULL, 0 },
@@ -616,3 +617,4 @@ int cmd_device(int argc, char **argv)
{
return handle_command_group(&device_cmd_group, argc, argv);
}
+#endif
@@ -1182,6 +1182,7 @@ static int cmd_filesystem_label(int argc, char **argv)
static const char filesystem_cmd_group_info[] =
"overall filesystem tasks and information";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group filesystem_cmd_group = {
filesystem_cmd_group_usage, filesystem_cmd_group_info, {
{ "df", cmd_filesystem_df, cmd_filesystem_df_usage, NULL, 0 },
@@ -1209,3 +1210,4 @@ int cmd_filesystem(int argc, char **argv)
{
return handle_command_group(&filesystem_cmd_group, argc, argv);
}
+#endif
@@ -634,6 +634,7 @@ out:
static const char inspect_cmd_group_info[] =
"query various internal information";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group inspect_cmd_group = {
inspect_cmd_group_usage, inspect_cmd_group_info, {
{ "inode-resolve", cmd_inspect_inode_resolve,
@@ -660,3 +661,4 @@ int cmd_inspect(int argc, char **argv)
{
return handle_command_group(&inspect_cmd_group, argc, argv);
}
+#endif
@@ -408,6 +408,7 @@ static int cmd_property_list(int argc, char **argv)
static const char property_cmd_group_info[] =
"modify properties of filesystem objects";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group property_cmd_group = {
property_cmd_group_usage, property_cmd_group_info, {
{ "get", cmd_property_get,
@@ -424,3 +425,4 @@ int cmd_property(int argc, char **argv)
{
return handle_command_group(&property_cmd_group, argc, argv);
}
+#endif
@@ -503,6 +503,7 @@ static int cmd_qgroup_limit(int argc, char **argv)
static const char qgroup_cmd_group_info[] =
"manage quota groups";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group qgroup_cmd_group = {
qgroup_cmd_group_usage, qgroup_cmd_group_info, {
{ "assign", cmd_qgroup_assign, cmd_qgroup_assign_usage,
@@ -525,3 +526,4 @@ int cmd_qgroup(int argc, char **argv)
{
return handle_command_group(&qgroup_cmd_group, argc, argv);
}
+#endif
@@ -194,6 +194,7 @@ static int cmd_quota_rescan(int argc, char **argv)
static const char quota_cmd_group_info[] =
"manage filesystem quota settings";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group quota_cmd_group = {
quota_cmd_group_usage, quota_cmd_group_info, {
{ "enable", cmd_quota_enable, cmd_quota_enable_usage, NULL, 0 },
@@ -208,3 +209,4 @@ int cmd_quota(int argc, char **argv)
{
return handle_command_group("a_cmd_group, argc, argv);
}
+#endif
@@ -545,6 +545,7 @@ static int cmd_replace_cancel(int argc, char **argv)
static const char replace_cmd_group_info[] =
"replace a device in the filesystem";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group replace_cmd_group = {
replace_cmd_group_usage, replace_cmd_group_info, {
{ "start", cmd_replace_start, cmd_replace_start_usage, NULL,
@@ -561,3 +562,4 @@ int cmd_replace(int argc, char **argv)
{
return handle_command_group(&replace_cmd_group, argc, argv);
}
+#endif
@@ -253,6 +253,7 @@ out:
static const char rescue_cmd_group_info[] =
"toolbox for specific rescue operations";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group rescue_cmd_group = {
rescue_cmd_group_usage, rescue_cmd_group_info, {
{ "chunk-recover", cmd_rescue_chunk_recover,
@@ -270,3 +271,4 @@ int cmd_rescue(int argc, char **argv)
{
return handle_command_group(&rescue_cmd_group, argc, argv);
}
+#endif
@@ -1788,6 +1788,7 @@ out:
static const char scrub_cmd_group_info[] =
"verify checksums of data and metadata";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group scrub_cmd_group = {
scrub_cmd_group_usage, scrub_cmd_group_info, {
{ "start", cmd_scrub_start, cmd_scrub_start_usage, NULL, 0 },
@@ -1802,3 +1803,4 @@ int cmd_scrub(int argc, char **argv)
{
return handle_command_group(&scrub_cmd_group, argc, argv);
}
+#endif
@@ -1226,6 +1226,7 @@ out:
static const char subvolume_cmd_group_info[] =
"manage subvolumes: create, delete, list, etc";
+#ifndef BTRFS_SEPARATED_BUILD
const struct cmd_group subvolume_cmd_group = {
subvolume_cmd_group_usage, subvolume_cmd_group_info, {
{ "create", cmd_subvol_create, cmd_subvol_create_usage, NULL, 0 },
@@ -1249,3 +1250,4 @@ int cmd_subvolume(int argc, char **argv)
{
return handle_command_group(&subvolume_cmd_group, argc, argv);
}
+#endif
@@ -132,14 +132,6 @@ int cmd_rescue(int argc, char **argv);
#include "help.h"
#endif
-/* Note: handle_command_group is defined in btrfs.c and cannot be
- * linked with separated subcommands because btrfs.o also contains a
- * "main" symbol. As a workaround, we simply return 1 (error) for
- * calls to handle_command_group() here (which is fine as this
- * functionality is not required for BTRFS_SEPARATED_BUILD commands).
- */
-#define handle_command_group(cmd_group,argc,argv) 1
-
/* forward declaration of main entry point (non-static are already declared above) */
#ifdef BTRFS_SEPARATED_STATIC_ENTRY
static int BTRFS_SEPARATED_ENTRY(int argc, char **argv);
Remove references to unneeded symbols when building separated subcommands: "btrfs-*.separated.o". Note that this patch still leaves unreferenced static symbols, which in turn makes the compiler warn about "unused function/variable". Stripping all symbols would imply adaptions in the source code (especially by moving "int handle_command_group" functionality into a separate compile unit). This is not a problem, ignore these warnings when building object: $(CC) -Wno-unused-function -Wno-unused-const-variable Signed-off-by: Axel Burri <axel@tty0.ch> --- Makefile | 2 +- cmds-balance.c | 2 ++ cmds-device.c | 2 ++ cmds-filesystem.c | 2 ++ cmds-inspect.c | 2 ++ cmds-property.c | 2 ++ cmds-qgroup.c | 2 ++ cmds-quota.c | 2 ++ cmds-replace.c | 2 ++ cmds-rescue.c | 2 ++ cmds-scrub.c | 2 ++ cmds-subvolume.c | 2 ++ commands.h | 8 -------- 13 files changed, 23 insertions(+), 9 deletions(-)