Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support successfully bootstrapping on OpenBSD. #1070

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Bootstrap.mak
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bsd: $(SRC)
$(CC) -o build/bootstrap/premake_bootstrap -DPREMAKE_NO_BUILTIN_SCRIPTS -DLUA_USE_POSIX -DLUA_USE_DLOPEN -I"$(LUA_DIR)" -I"$(LUASHIM_DIR)" $? -lm
./build/bootstrap/premake_bootstrap embed
./build/bootstrap/premake_bootstrap --to=build/bootstrap gmake
$(MAKE) -C build/bootstrap -j`getconf _NPROCESSORS_ONLN` config=$(CONFIG)
$(MAKE) -C build/bootstrap -j`getconf NPROCESSORS_ONLN` config=$(CONFIG)

windows-base: $(SRC)
$(SILENT) if exist .\bin rmdir /s /q .\bin
Expand Down
2 changes: 1 addition & 1 deletion src/host/premake.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ int premake_locate_executable(lua_State* L, const char* argv0)
}
#endif

#if PLATFORM_BSD
#if PLATFORM_BSD && !defined(__OpenBSD__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems not great - is there something that can be done to support OpenBSD in this block instead? What does this block do on OpenBSD? I got it working on FreeBSD by adding that sysctl call, is there something similar for OpenBSD?

Sorry to bombard you with questions! I'm keen to see what we can do to improve the BSD situation!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to a comment in the latter stackoverflow post referred to in premake_locate_executable()'s comments, OpenBSD does not support other methods than using argv[0]. I'm no expert in *BSD, so I cannot be absolutely sure if this is true. However, that particular piece of code fails to compile on OpenBSD due to the undeclared identifier KERN_PROC_PATHNAME.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair enough, perhaps wrapping that block instead would be better? Not required, if the none of it will work on OpenBSD it's probably pointless reducing it down to what doesn't compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only KERN_PROC_PATHNAME was left out on OpenBSD, I don't think the sysctl would do anything meanful anymore even if it would compile; if that's what you meant. Also here's a comment by Theo de Raadt about finding executable path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that entire if block that contains the call to sysctl, but it's not really worth the effort. Thanks for the link, it's a pretty interesting discussion.

int len = readlink("/proc/curproc/file", buffer, PATH_MAX - 1);
if (len < 0)
len = readlink("/proc/curproc/exe", buffer, PATH_MAX - 1);
Expand Down