Skip to content

Commit

Permalink
Merge pull request #154 from snowball-lang/revert-152-dev
Browse files Browse the repository at this point in the history
Revert "Make repo a flake and make ld-linux be dynamically located"
  • Loading branch information
mauro-balades authored Dec 12, 2023
2 parents a93550e + 2e09027 commit ff671e0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 193 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,4 @@ install_manifest.txt
compile_commands.json
callgrind.out.*

install_deps_temp/

.direnv
result
.cmake
install_deps_temp/
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ if (DEFINED ENV{BUILD_FOR_CE})
add_compile_definitions(_SNOWBALL_BUILD_FOR_CE="1")
endif()

add_compile_definitions(LD_PATH="ld")
if (${BUILD_FOR_WIN})
add_compile_definitions(LD_PATH="ld")
else()
add_compile_definitions(LD_PATH="/usr/bin/ld")
endif()


add_compile_definitions(STATICLIB_DIR="${STATICLIB_DIR}")

Expand Down Expand Up @@ -348,4 +353,4 @@ install(TARGETS snowballexe EXPORT MyLibConfig
# TODO: as a feature:
# install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

#install(FILES ${std_sn_files} DESTINATION ${HOME_DIR}/${STATICLIB_DIR}/${_SNOWBALL_LIBRARY_DIR})
#install(FILES ${std_sn_files} DESTINATION ${HOME_DIR}/${STATICLIB_DIR}/${_SNOWBALL_LIBRARY_DIR})
59 changes: 0 additions & 59 deletions flake.lock

This file was deleted.

109 changes: 0 additions & 109 deletions flake.nix

This file was deleted.

20 changes: 3 additions & 17 deletions src/builder/linker/linux/ld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../../../constants.h"
#include "../Linker.h"

#include <dlfcn.h>
#include <filesystem>
namespace fs = std::filesystem;

Expand All @@ -31,25 +30,12 @@ void Linker::constructLinkerArgs(std::string& input, std::string& output, std::v
if (ctx->withStd) {
// TODO: check if this works for all platforms
linkerArgs.push_back("-dynamic-linker");

fs::path ld_linux_path;

void* handle = dlopen("ld-linux-x86-64.so.2", RTLD_LAZY);
if (!handle) { DEBUG_CODEGEN("Error getting library path: %s", dlerror()); }

Dl_info info;
if (dladdr(handle, &info)) {
ld_linux_path = info.dli_fname;
} else {
DEBUG_CODEGEN("Error getting library path: %s", dlerror());
}

linkerArgs.push_back(ld_linux_path);
linkerArgs.push_back("/lib64/ld-linux-x86-64.so.2");

auto path = std::string("/usr") + PATH_SEPARATOR + _SNOWBALL_LIBRARY_OBJ;
auto triple = getPlatformTriple();
assert(!triple.empty() && "Unsupported platform for linking!");

Check warning on line 37 in src/builder/linker/linux/ld.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/builder/linker/linux/ld.cc:37:5 [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead
auto platformPath = ld_linux_path.parent_path();
auto platformPath = fs::path(path) / triple;
linkerArgs.push_back(platformPath / "crt1.o");
linkerArgs.push_back(platformPath / "crti.o");
if (!isIAMCU) {

Check warning on line 41 in src/builder/linker/linux/ld.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

/src/builder/linker/linux/ld.cc:41:5 [bugprone-branch-clone]

if with identical then and else branches
Expand Down Expand Up @@ -98,4 +84,4 @@ std::string Linker::getSharedLibraryName(std::string& library) { return library
} // namespace linker
} // namespace snowball

#endif
#endif

0 comments on commit ff671e0

Please sign in to comment.