Skip to content

Commit 08663eb

Browse files
committed
simpleperf: fix mac build.
I forgot that mac doesn't support whole static library. Change to static library to avoid hiting the same problem in the future. Bug: 26962895 Change-Id: Ia8e26c2e1cf7621391e00e100b22b7ed451dfa32 (cherry picked from commit ff7465c)
1 parent 025745a commit 08663eb

8 files changed

+35
-21
lines changed

simpleperf/Android.mk

+6-15
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ LOCAL_MODULE_TAGS := debug
147147
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
148148
LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
149149
LOCAL_SRC_FILES := main.cpp
150-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
151-
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
150+
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
152151
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
153152
LOCAL_MULTILIB := first
154153
include $(BUILD_EXECUTABLE)
@@ -162,9 +161,7 @@ LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
162161
LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
163162
LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
164163
LOCAL_SRC_FILES := main.cpp
165-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
166-
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
167-
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
164+
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
168165
LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin)
169166
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
170167
LOCAL_SHARED_LIBRARIES_windows := $(simpleperf_shared_libraries_host_windows)
@@ -202,8 +199,7 @@ LOCAL_SRC_FILES := \
202199
$(simpleperf_unit_test_src_files) \
203200
$(simpleperf_unit_test_src_files_linux) \
204201

205-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
206-
LOCAL_STATIC_LIBRARIES += $(simpleperf_static_libraries_target)
202+
LOCAL_STATIC_LIBRARIES += libsimpleperf $(simpleperf_static_libraries_target)
207203
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
208204
LOCAL_MULTILIB := first
209205
include $(BUILD_NATIVE_TEST)
@@ -218,9 +214,7 @@ LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
218214
LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
219215
LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
220216
LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux)
221-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
222-
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
223-
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
217+
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
224218
LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin)
225219
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
226220
LOCAL_SHARED_LIBRARIES_windows := $(simpleperf_shared_libraries_host_windows)
@@ -240,9 +234,8 @@ LOCAL_CLANG := true
240234
LOCAL_MODULE := simpleperf_cpu_hotplug_test
241235
LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
242236
LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
243-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
237+
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
244238
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
245-
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
246239
LOCAL_MULTILIB := first
247240
include $(BUILD_NATIVE_TEST)
248241

@@ -254,9 +247,7 @@ LOCAL_MODULE_HOST_OS := linux
254247
LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
255248
LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
256249
LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
257-
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
258-
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
259-
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
250+
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
260251
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
261252
LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
262253
LOCAL_MULTILIB := first

simpleperf/cmd_dumprecord.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ void DumpRecordCommand::DumpFeatureSection() {
207207
}
208208
}
209209

210-
__attribute__((constructor)) static void RegisterDumpRecordCommand() {
210+
void RegisterDumpRecordCommand() {
211211
RegisterCommand("dump", [] { return std::unique_ptr<Command>(new DumpRecordCommand); });
212212
}

simpleperf/cmd_help.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ void HelpCommand::PrintLongHelpForOneCommand(const Command& command) {
7373
printf("%s\n", command.LongHelpString().c_str());
7474
}
7575

76-
__attribute__((constructor)) static void RegisterHelpCommand() {
76+
void RegisterHelpCommand() {
7777
RegisterCommand("help", [] { return std::unique_ptr<Command>(new HelpCommand); });
7878
}

simpleperf/cmd_list.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ bool ListCommand::Run(const std::vector<std::string>& args) {
8282
return true;
8383
}
8484

85-
__attribute__((constructor)) static void RegisterListCommand() {
85+
void RegisterListCommand() {
8686
RegisterCommand("list", [] { return std::unique_ptr<Command>(new ListCommand); });
8787
}

simpleperf/cmd_record.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,6 @@ void RecordCommand::CollectHitFileInfo(Record* record) {
844844
}
845845
}
846846

847-
__attribute__((constructor)) static void RegisterRecordCommand() {
847+
void RegisterRecordCommand() {
848848
RegisterCommand("record", [] { return std::unique_ptr<Command>(new RecordCommand()); });
849849
}

simpleperf/cmd_report.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,6 @@ void ReportCommand::PrintCallGraphEntry(size_t depth, std::string prefix,
773773
}
774774
}
775775

776-
__attribute__((constructor)) static void RegisterReportCommand() {
776+
void RegisterReportCommand() {
777777
RegisterCommand("report", [] { return std::unique_ptr<Command>(new ReportCommand()); });
778778
}

simpleperf/cmd_stat.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,6 @@ bool StatCommand::ShowCounters(const std::vector<CountersInfo>& counters, double
411411
return true;
412412
}
413413

414-
__attribute__((constructor)) static void RegisterStatCommand() {
414+
void RegisterStatCommand() {
415415
RegisterCommand("stat", [] { return std::unique_ptr<Command>(new StatCommand); });
416416
}

simpleperf/command.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,26 @@ const std::vector<std::string> GetAllCommandNames() {
6868
}
6969
return names;
7070
}
71+
72+
extern void RegisterDumpRecordCommand();
73+
extern void RegisterHelpCommand();
74+
extern void RegisterListCommand();
75+
extern void RegisterRecordCommand();
76+
extern void RegisterReportCommand();
77+
extern void RegisterStatCommand();
78+
79+
class CommandRegister {
80+
public:
81+
CommandRegister() {
82+
RegisterDumpRecordCommand();
83+
RegisterHelpCommand();
84+
RegisterReportCommand();
85+
#if defined(__linux__)
86+
RegisterListCommand();
87+
RegisterRecordCommand();
88+
RegisterStatCommand();
89+
#endif
90+
}
91+
};
92+
93+
CommandRegister command_register;

0 commit comments

Comments
 (0)