Skip to content

Commit 739e83f

Browse files
scchangargrahul
authored andcommitted
SWDEV-355608 - deprecate/cleanup hipcc link flags
- deprecate -use-staticlib, -use-sharedlib which no longer provide any functional values - use --hip-link instead of specifying the HIP runtime by name when linking - fix linker option bug in HIT test's cmake - update build options for unit tests requiring pthread or rt Change-Id: Ib49978773c80fb40c71dc52b050ce921943ee3e4
1 parent d8f39ab commit 739e83f

Some content is hidden

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

42 files changed

+93
-72
lines changed

bin/hipcc.pl

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ BEGIN
199199
print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n");
200200
}
201201

202-
$HIPLDFLAGS .= " -L\"$HIP_LIB_PATH\"";
203-
if ($isWindows) {
204-
$HIPLDFLAGS .= " -lamdhip64";
205-
}
206202
if ($HIP_CLANG_HCC_COMPAT_MODE) {
207203
## Allow __fp16 as function parameter and return type.
208204
$HIPCXXFLAGS .= " -Xclang -fallow-half-arguments-and-returns -D__HIP_HCC_COMPAT_MODE__=1";
@@ -245,8 +241,6 @@ BEGIN
245241
my $printLDFlags = 0; # print HIPLDFLAGS
246242
my $runCmd = 1;
247243
my $buildDeps = 0;
248-
my $linkType = 1;
249-
my $setLinkType = 0;
250244
my $hsacoVersion = 0;
251245
my $funcSupp = 0; # enable function support
252246
my $rdc = 0; # whether -fgpu-rdc is on
@@ -361,16 +355,11 @@ BEGIN
361355
$compileOnly = 1;
362356
$buildDeps = 1;
363357
}
364-
if(($trimarg eq '-use-staticlib') and ($setLinkType eq 0))
365-
{
366-
$linkType = 0;
367-
$setLinkType = 1;
368-
$swallowArg = 1;
358+
if($trimarg eq '-use-staticlib') {
359+
print "Warning: The -use-staticlib option has been deprecated and is no longer needed.\n"
369360
}
370-
if(($trimarg eq '-use-sharedlib') and ($setLinkType eq 0))
371-
{
372-
$linkType = 1;
373-
$setLinkType = 1;
361+
if($trimarg eq '-use-sharedlib') {
362+
print "Warning: The -use-sharedlib option has been deprecated and is no longer needed.\n"
374363
}
375364
if($arg =~ m/^-O/)
376365
{
@@ -558,12 +547,6 @@ BEGIN
558547
$HIPCXXFLAGS .= " --cuda-host-only";
559548
}
560549

561-
# Add --hip-link only if it is compile only and -fgpu-rdc is on.
562-
if ($rdc and !$compileOnly and $HIP_PLATFORM eq 'amd') {
563-
$HIPLDFLAGS .= " --hip-link";
564-
$HIPLDFLAGS .= $HIPLDARCHFLAGS;
565-
}
566-
567550
# hipcc currrently requires separate compilation of source files, ie it is not possible to pass
568551
# CPP files combined with .O files
569552
# Reason is that NVCC uses the file extension to determine whether to compile in CUDA mode or
@@ -588,18 +571,16 @@ BEGIN
588571
$HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";
589572
}
590573
}
591-
if (not $isWindows) {
592-
$HIPLDFLAGS .= " -lgcc_s -lgcc -lpthread -lm -lrt";
593-
}
594574

595-
if (not $isWindows and not $compileOnly) {
596-
if ($linkType eq 0) {
597-
$toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
598-
} else {
599-
$toolArgs = ${toolArgs} . " -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 ";
600-
}
575+
if (!$compileOnly) {
576+
$HIPLDFLAGS .= " --hip-link";
577+
if ($rdc) {
578+
$HIPLDFLAGS .= $HIPLDARCHFLAGS;
579+
}
580+
if (not $isWindows) {
581+
$HIPLDFLAGS .= " --rtlib=compiler-rt -unwindlib=libgcc";
601582

602-
$toolArgs .= " -L$HIP_CLANG_RT_LIB -lclang_rt.builtins-x86_64 "
583+
}
603584
}
604585
}
605586

samples/0_Intro/square/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $ cd ~/hip/samples/0_Intro/square
2121
$ make
2222
/opt/rocm/hip/bin/hipify-perl square.cu > square.cpp
2323
/opt/rocm/hip/bin/hipcc square.cpp -o square.out
24-
/opt/rocm/hip/bin/hipcc -use-staticlib square.cpp -o square.out.static
24+
/opt/rocm/hip/bin/hipcc square.cpp -o square.out
2525
```
2626
- Execute file
2727
```

tests/catch/multiproc/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ set(LINUX_TEST_SRC
1919
)
2020

2121
add_custom_target(dummy_kernel.code COMMAND ${CMAKE_CXX_COMPILER} --genco ${CMAKE_CURRENT_SOURCE_DIR}/dummy_kernel.cpp -o ${CMAKE_CURRENT_BINARY_DIR}/../multiproc/dummy_kernel.code -I${CMAKE_CURRENT_SOURCE_DIR}/../../../../include/ -I${CMAKE_CURRENT_SOURCE_DIR}/../../include)
22+
if (UNIX)
23+
set(__LINKER_LIBS__ pthread)
24+
endif()
2225

2326
# the last argument linker libraries is required for this test but optional to the function
2427
if(HIP_PLATFORM MATCHES "nvidia")
@@ -30,7 +33,6 @@ elseif(HIP_PLATFORM MATCHES "amd")
3033
hip_add_exe_to_target(NAME MultiProc
3134
TEST_SRC ${LINUX_TEST_SRC}
3235
TEST_TARGET_NAME build_tests
33-
LINKER_LIBS ${CMAKE_DL_LIBS})
36+
LINKER_LIBS ${CMAKE_DL_LIBS} ${__LINKER_LIBS__})
3437
endif()
3538
add_dependencies(build_tests dummy_kernel.code)
36-

tests/catch/unit/device/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ set_source_files_properties(hipDeviceGetP2PAttribute.cc PROPERTIES COMPILE_FLAGS
4343
add_executable(getDeviceCount EXCLUDE_FROM_ALL getDeviceCount_exe.cc)
4444
add_executable(hipDeviceGetP2PAttribute EXCLUDE_FROM_ALL hipDeviceGetP2PAttribute_exe.cc)
4545

46+
if (UNIX)
47+
set(__LINKER_LIBS__ pthread)
48+
endif()
49+
4650
hip_add_exe_to_target(NAME DeviceTest
4751
TEST_SRC ${TEST_SRC}
4852
TEST_TARGET_NAME build_tests
49-
COMPILE_OPTIONS -std=c++14)
53+
COMPILE_OPTIONS -std=c++14
54+
LINKER_LIBS ${__LINKER_LIBS__})
5055

5156
add_dependencies(DeviceTest getDeviceCount)
5257
add_dependencies(DeviceTest hipDeviceGetP2PAttribute)

tests/catch/unit/deviceLib/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(TEST_SRC
1818
if(UNIX)
1919
set(TEST_SRC ${TEST_SRC}
2020
deviceAllocation.cc)
21+
set(__LINKER_LIBS__ pthread)
2122
endif()
2223

2324
# AMD only tests
@@ -86,7 +87,7 @@ endif()
8687
hip_add_exe_to_target(NAME UnitDeviceTests
8788
TEST_SRC ${TEST_SRC}
8889
TEST_TARGET_NAME build_tests
89-
LINKER_LIBS hiprtc)
90+
LINKER_LIBS hiprtc ${__LINKER_LIBS__})
9091
elseif(HIP_PLATFORM MATCHES "nvidia")
9192
hip_add_exe_to_target(NAME UnitDeviceTests
9293
TEST_SRC ${TEST_SRC}

tests/catch/unit/errorHandling/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ set(TEST_SRC
66
hipPeekAtLastError.cc
77
)
88

9+
if (UNIX)
10+
set(__LINKER_LIBS__ pthread)
11+
endif()
12+
913
hip_add_exe_to_target(NAME ErrorHandlingTest
1014
TEST_SRC ${TEST_SRC}
1115
TEST_TARGET_NAME build_tests
12-
COMPILE_OPTIONS -std=c++14)
16+
LINKER_LIBS ${__LINKER_LIBS__}
17+
COMPILE_OPTIONS -std=c++14)

tests/catch/unit/event/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ if(HIP_PLATFORM MATCHES "amd")
2020
set(TEST_SRC ${TEST_SRC} ${AMD_SRC})
2121
endif()
2222

23+
if (UNIX)
24+
set(__LINKER_LIBS__ pthread)
25+
endif()
26+
2327
hip_add_exe_to_target(NAME EventTest
2428
TEST_SRC ${TEST_SRC}
2529
TEST_TARGET_NAME build_tests)

tests/catch/unit/graph/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ set(TEST_SRC
8383
hipUserObjectCreate.cc
8484
)
8585

86+
if (UNIX)
87+
set(__LINKER_LIBS__ pthread)
88+
endif()
89+
8690
hip_add_exe_to_target(NAME GraphsTest
8791
TEST_SRC ${TEST_SRC}
88-
TEST_TARGET_NAME build_tests)
92+
TEST_TARGET_NAME build_tests
93+
LINKER_LIBS ${__LINKER_LIBS__})

tests/catch/unit/memory/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ if(UNIX)
182182
set(TEST_SRC ${TEST_SRC}
183183
hipHmmOvrSubscriptionTst.cc
184184
hipMemoryAllocateCoherent.cc)
185+
186+
set(__LINKER_LIBS__ pthread)
185187
endif()
186188

187189
hip_add_exe_to_target(NAME MemoryTest
188190
TEST_SRC ${TEST_SRC}
189-
TEST_TARGET_NAME build_tests)
191+
TEST_TARGET_NAME build_tests
192+
LINKER_LIBS ${__LINKER_LIBS__})

tests/catch/unit/multiThread/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ set(TEST_SRC
55
hipMultiThreadStreams2.cc
66
)
77

8+
if (UNIX)
9+
set(__LINKER_LIBS__ pthread)
10+
endif()
11+
812
hip_add_exe_to_target(NAME MultiThreadTest
913
TEST_SRC ${TEST_SRC}
10-
TEST_TARGET_NAME build_tests)
14+
TEST_TARGET_NAME build_tests
15+
LINKER_LIBS ${__LINKER_LIBS__})

0 commit comments

Comments
 (0)