Skip to content

Commit

Permalink
Merge pull request #2961 from ROCm/add-lib-changes-6.1-2948
Browse files Browse the repository at this point in the history
Append so_version for loading shared libraries (changes from PR#2948 commit 7374d52 in develop)
  • Loading branch information
vamovsik authored Apr 17, 2024
2 parents 84ec399 + ab39bfc commit 11d19e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
25 changes: 22 additions & 3 deletions src/register_target.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,6 +26,7 @@
#include <migraphx/register_target.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/dynamic_loader.hpp>
#include <migraphx/version.h>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
Expand Down Expand Up @@ -58,10 +59,28 @@ target make_target(const std::string& name)
{
#ifdef _WIN32
std::string target_name = "migraphx_" + name + ".dll";
store_target_lib(dynamic_loader(target_name));
#else
std::string target_name = "libmigraphx_" + name + ".so";
std::string target_name = "libmigraphx_" + name + ".so";
std::string so_major_version = "." + std::to_string(MIGRAPHX_SO_MAJOR_VERSION);

// Try to load library with so_major_version appended to the name.
// If library with so_major_version name is not found,
// try loading the library without the so_major_version name appended.
// For example, if "libmigraphx_ref.so.2010000" is not found,
// try loading "libmigraphx_ref.so".
try
{
// Default to loading shared libraries with
// so_major_version appended.
store_target_lib(dynamic_loader(target_name + so_major_version));
}
catch(...)
{
// Load the library without the so_major_version in the name.
store_target_lib(dynamic_loader(target_name));
}
#endif
store_target_lib(dynamic_loader(target_name));
}
const auto it = target_map().find(name);
if(it == target_map().end())
Expand Down
6 changes: 5 additions & 1 deletion src/version.h.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,4 +26,8 @@
#define MIGRAPHX_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define MIGRAPHX_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define MIGRAPHX_VERSION_TWEAK "@PROJECT_VERSION_TWEAK@"
#define MIGRAPHX_SO_MAJOR_VERSION \
@PROJECT_VERSION_MAJOR@ * 1000 * 1000 + \
@PROJECT_VERSION_MINOR@ * 1000 + \
@PROJECT_VERSION_PATCH@
// clang-format on

0 comments on commit 11d19e3

Please sign in to comment.