Skip to content

Commit 7848214

Browse files
committed
Remove whole_archieve in paddle.
1 parent 89422a4 commit 7848214

File tree

102 files changed

+427
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+427
-41
lines changed

cmake/util.cmake

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,18 @@
77
# Rest Arguments: libraries which link together.
88
function(target_circle_link_libraries TARGET_NAME)
99
if(APPLE)
10-
set(LIBS)
11-
set(inArchive OFF)
12-
set(libsInArgn)
13-
14-
foreach(arg ${ARGN})
15-
if(${arg} STREQUAL "ARCHIVE_START")
16-
set(inArchive ON)
17-
elseif(${arg} STREQUAL "ARCHIVE_END")
18-
set(inArchive OFF)
19-
else()
20-
if(inArchive)
21-
list(APPEND LIBS "-Wl,-force_load")
22-
endif()
23-
list(APPEND LIBS ${arg})
24-
list(APPEND libsInArgn ${arg})
25-
endif()
26-
endforeach()
10+
set(LIBS ${ARGN})
11+
set(libsInArgn ${ARGN})
12+
list(REVERSE libsInArgn)
2713
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2814
list(APPEND LIBS "-undefined dynamic_lookup")
2915
endif()
30-
list(REVERSE libsInArgn)
3116
target_link_libraries(${TARGET_NAME}
3217
${LIBS}
3318
${libsInArgn})
3419

3520
else() # LINUX
3621
set(LIBS)
37-
38-
foreach(arg ${ARGN})
39-
if(${arg} STREQUAL "ARCHIVE_START")
40-
list(APPEND LIBS "-Wl,--whole-archive")
41-
elseif(${arg} STREQUAL "ARCHIVE_END")
42-
list(APPEND LIBS "-Wl,--no-whole-archive")
43-
else()
44-
list(APPEND LIBS ${arg})
45-
endif()
46-
endforeach()
47-
4822
target_link_libraries(${TARGET_NAME}
4923
"-Wl,--start-group"
5024
${LIBS}
@@ -84,21 +58,17 @@ function(link_paddle_exe TARGET_NAME)
8458
if(PADDLE_WITH_INTERNAL)
8559
set(INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter)
8660
target_circle_link_libraries(${TARGET_NAME}
87-
ARCHIVE_START
8861
paddle_internal_gserver
8962
paddle_internal_owlqn
90-
ARCHIVE_END
9163
paddle_internal_parameter)
9264
else()
9365
set(INTERAL_LIBS "")
9466
endif()
9567

9668
target_circle_link_libraries(${TARGET_NAME}
97-
ARCHIVE_START
9869
paddle_gserver
9970
paddle_function
10071
${METRIC_LIBS}
101-
ARCHIVE_END
10272
paddle_pserver
10373
paddle_trainer_lib
10474
paddle_network
@@ -165,7 +135,9 @@ endfunction()
165135
# TARGET_NAME: the unittest target name, same as executable file name
166136
# Rest Arguments: the source files to compile this unittest.
167137
macro(add_unittest_without_exec TARGET_NAME)
168-
add_executable(${TARGET_NAME} ${ARGN})
138+
add_executable(${TARGET_NAME}
139+
${PROJ_ROOT}/paddle/trainer/ForceLinkFiles.cpp
140+
${ARGN})
169141
link_paddle_test(${TARGET_NAME})
170142
add_style_check_target(${TARGET_NAME} ${ARGN})
171143
endmacro()

paddle/function/ContextProjectionOp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License. */
1515
#include "ContextProjectionOp.h"
1616
#include "paddle/math/Matrix.h"
1717
#include "paddle/math/Vector.h"
18-
18+
#include "paddle/utils/ForceLink.h"
1919
namespace paddle {
2020

2121
template <>
@@ -371,3 +371,5 @@ REGISTER_TYPED_FUNC(ContextProjectionBackwardWeight,
371371
ContextProjectionBackwardWeightFunc);
372372
#endif
373373
} // namespace paddle
374+
375+
PADDLE_REGISTER_FORCE_LINK_FILE(context_proj_ops);

paddle/function/CrossMapNormalOp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ limitations under the License. */
1414

1515
#include "CrossMapNormalOp.h"
1616
#include "paddle/math/Vector.h"
17+
#include "paddle/utils/ForceLink.h"
1718

1819
namespace paddle {
1920

@@ -225,3 +226,5 @@ REGISTER_TYPED_FUNC(CrossMapNormalGrad, GPU, CrossMapNormalGradFunc);
225226
#endif
226227

227228
} // namespace paddle
229+
230+
PADDLE_REGISTER_FORCE_LINK_FILE(cross_map_norm_ops);

paddle/gserver/activations/ActivationFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ limitations under the License. */
2222
#include <type_traits>
2323
#include "paddle/parameter/Argument.h"
2424
#include "paddle/utils/ClassRegistrar.h"
25-
25+
#include "paddle/utils/ForceLink.h"
2626
#include "paddle/utils/Logging.h"
2727

28+
PADDLE_REGISTER_FORCE_LINK_FILE(activations);
2829
namespace paddle {
2930

3031
static ClassRegistrar<ActivationFunction> gActivationRegistrar;

paddle/gserver/dataproviders/DataProvider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ limitations under the License. */
1717
#include <unistd.h>
1818
#include <algorithm>
1919
#include "ProtoDataProvider.h"
20+
#include "paddle/utils/ForceLink.h"
2021
#include "paddle/utils/Logging.h"
2122
#include "paddle/utils/StringUtil.h"
2223
#include "paddle/utils/Util.h"
2324

25+
PADDLE_REGISTER_FORCE_LINK_FILE(base_data_providers);
26+
2427
namespace paddle {
2528

2629
void BufferBatch::swap(BufferBatch* bufBatch) {

paddle/gserver/dataproviders/MultiDataProvider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ limitations under the License. */
1414

1515
#include "MultiDataProvider.h"
1616
#include <algorithm>
17+
#include "paddle/utils/ForceLink.h"
1718
#include "paddle/utils/Logging.h"
1819
#include "paddle/utils/Util.h"
1920

21+
PADDLE_REGISTER_FORCE_LINK_FILE(multi_data_dp);
22+
2023
namespace paddle {
2124

2225
using namespace std;

paddle/gserver/dataproviders/ProtoDataProvider.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ limitations under the License. */
1616
#include <algorithm>
1717
#include <fstream>
1818
#include <istream>
19+
#include "DataProviderGroup.h"
20+
#include "paddle/utils/ForceLink.h"
21+
#include "paddle/utils/Logging.h"
1922
#include "paddle/utils/StringUtil.h"
2023
#include "paddle/utils/Util.h"
2124

22-
#include "DataProviderGroup.h"
23-
#include "paddle/utils/Logging.h"
25+
PADDLE_REGISTER_FORCE_LINK_FILE(proto_dp);
2426

2527
DEFINE_double(memory_threshold_on_load_data,
2628
1.0,

paddle/gserver/dataproviders/PyDataProvider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ limitations under the License. */
1515
#include "PyDataProvider.h"
1616
#include <fenv.h>
1717
#include "paddle/utils/Excepts.h"
18+
#include "paddle/utils/ForceLink.h"
1819
#include "paddle/utils/PythonUtil.h"
1920
#include "paddle/utils/Util.h"
2021

22+
PADDLE_REGISTER_FORCE_LINK_FILE(py_dp);
23+
2124
namespace paddle {
2225

2326
#ifndef PADDLE_NO_PYTHON

paddle/gserver/dataproviders/PyDataProvider2.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ limitations under the License. */
2525

2626
#include "DataProvider.h"
2727

28+
#include "paddle/utils/ForceLink.h"
2829
#include "paddle/utils/Locks.h"
2930
#include "paddle/utils/PythonUtil.h"
3031
#include "paddle/utils/Stat.h"
3132

33+
PADDLE_REGISTER_FORCE_LINK_FILE(py_dp2);
34+
3235
namespace paddle {
3336

3437
namespace unittest {

paddle/gserver/evaluators/CTCErrorEvaluator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ limitations under the License. */
1414

1515
#include "Evaluator.h"
1616
#include "paddle/gserver/gradientmachines/NeuralNetwork.h"
17+
#include "paddle/utils/ForceLink.h"
18+
19+
PADDLE_REGISTER_FORCE_LINK_FILE(ctc_evaluator);
1720

1821
namespace paddle {
1922

0 commit comments

Comments
 (0)