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

Linux Port WIP #295

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Conversation

Mallchad
Copy link

@Mallchad Mallchad commented Aug 5, 2024

Hiya, good day,
I wanted to make a small Linux debugger and saw you open sourced a half decent debugger and thought I'd see how far I could get porting it as a hobby instead of torturing myself. I've done a big chunk now and saw you're doing little proddings on the Linux version so I thought I'd share what I have so far.

It's in an extremely unstable and tempremental state right now but a lot of it shouldn't be too stupid and I tried to comment as much findings as possible. So you can look over it for insight if you wish and whatever but **please be warned ** I have not had a chance to test hardly anything yet properly because I wanted some kind of minimum-working-set to play with.

I tried to look over some of the other pulls/issues for other people that worked on it and it seemed there was not much progress there so that's a shame... One had mostly just basic stub outs and bugfixes and the other had a minimal OpenGL API although I'm not super sure is the target you want long term because of how janky OpenGL device selection is.

…the linux layer

[metagen_w32] Fixed: Don't modify file creation time
This isn't really a big deal but I feel like ist not the intention of
os_file_set_times and its also just bad form in general to modify access times beacuse it obliterates
the very limited context the OS will save about our files. Feel free to revert.

[metagen_linux] Added: Auto allocation of 1GB huge_pages on os_reserve_large
I don't know if we actually want this or not but I figured I would at least
throw it out there because its not unusual to run up multi-gigabyte debug data
on very complex projects so its absolutely a thing that would be worth looking
into for performance / OS-level fragmentation and also crash resistance

[metagen_strings] Added: Function to find first-occurance of a substring 'str8_match_substr'
This returns a range of where the match was found.

[metagen_linux] Added: Dependencies 'libpthread libuuid'

[metagen_linux] Fixed: Leftover bool usage was changed to B32 and int usage

NOTE: Nothing has been tested at this point, too annoying, too many missing
functions, hard to test when it doesn't build
…the linux layer

Documentation: Changed some links to be on their own comment line.
This makes it easier to copy and discern there's a usable link present

Added: Implementation for os_id_from_file from TODO
TODO(nick): querry struct stat with fstat(2) and use st_dev and st_ino as ids

Added: Implementation for os_full_path_from_path from TODO
TODO: realpath can be used to resolve full path

Fixed: Some erroneous dot (.) and arrow (->) notation
Added: Some helper typedefs for long and hard to remember Linux-specific types
Added: Linking for pthread, dl, and rt
Tweak: Changed RAD_BUILD_ALL to just build_all.
Should be more consistent with other variables now and is documented

Fixed: Random pushd and pwd commands echoing unwanted directories
Documentation: Added some basic comments / thoughts about the build system
Focused mainly around memory allocations this time

[Metagen Linux] Fixed: Wrong lnx function name call
[Build System] Fixed: Wrong syntax for calling metagen.exe in current directory
[Metagen Linux] Fixed: os_commit should now be backed by physical memory like in Windows
Removed: Hugepage support temporarily, it can't function without additional work
Fixed: Potential edge case where munmap doesn't sync to disk
Tweak: Try to populate all mmap calls on either commit or view open for performance
Maintenance: Renamed lnx_fstat and lnx_date to LNX_fstat to be closer in line with other types
Fixed: Potential fix for setting up condition variable in wrong order

[Build Batch] Added: Debug environmental variable for skipping running metagen
NOTE: This is mostly because I didn't want to deal with erroring and crashing
programs but wanted to still get compiler output for metagen.
…mpiles and runs

I haven't verified how well much of the code works but the one thing metagen
uses, the OS filter iterator, seems happy and I checked a good few of the values
it spat out. The only thing left is the condition variable broadcast and a few
long winded things I don't know how to compelte the implementation on. I don't
really know what a condition variable is or what a broadcast for it is so moving
to testing other things first.

Also the OS_SystemPath_ModuleLoad is not done.

Maintenance: Sorted include lines- because nice.

[Build Batch] Fixed: Exiting with fail status (1) on successful compile instead of success
[Build Batch] Fixed: All targets specified should build like it's supposed to in the windows version
Fixed: metagen section exiting script early

[Third Party]
[rad_lzb_simple] Fixed: RR_ASSERT did not support clang traps which was preventing compiles
Fixed: Using standard breaking label (done:) syntax without a statement (done: statement;)
RANT: So aparently this entire time MSVC and gcc were using incompatible
standard syntax for the label syntax, notice how I said syntax not
statement. Because goto is not a staement- it's a "labelled-staement" whatever
that means, which is just ever so slightly different to a regular statement,
which is ended by a semicolon (;), gcc and clang (as far I know) just auto-completes the statement.

And this is your daily reminder that the C/C++ Standards Commitee are stupid and
failed to create a stable and portable language, and you should never take
anything for granted unless its explicitly stated in the standard. Have. Fun. Programming.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

[Metagen Linux] Removed: 'pthread.so' load, it was a mistake the compiler sets it up automatically
Fixed: Maybe fix for 'lnx_initial_path' not being setup properly or having integer under/overflow

[Raddbg Linux] Removed: 'pthread.so' load, it was a mistake the compiler sets it up automatically
Fixed: Maybe fix for 'lnx_initial_path' not being setup properly or having integer under/overflow
Removed: Depreceated os_get_command_line_arguments it seems to be unused and the API changed.

[Base Strings] Added: str8_substring_match from metagen
…usly

Fixed: 'OS_AccessFlag_Shared' not being valid in this context
Added: Minor assert for 'lnx_entity_from_handle'
[Metagen Linux Linux]
Fixed: 'tctx_release()' being removed possibly erroneously
[Build Batch]
Fixed: Missing quoting for git hash
Fixed: '__VA_ARGS' on various macros erroring with zero arguments. So use '##__VA_ARGS' extension instead.
[DF GFX] Fixed: Superflous OS-specific 'Sleep()' function
[Build Batch] Added: Erorr-by-default for invalid memory ordering
[Core Linux]
Fixed: Slightly different os_set_large_pages semantics to win32 API
Fixed: 'actual_size_out' not being written to with ring buffers
Fixed: 'os_machine_name' being completely broken
NOTE: The logic looks sort of correct but a return code was interpreted wrong,
and the rest was completely irrelevant, the hostname spec caps to 253 ASCII
chars precisely I believe. So I just replaced nearly the whole function with a
minimal and working version

Fixed: 'lnx_environment' not being set properly because of Linux's unspecified virtual filesize
Fixed: 'os_file_open' Typo
Fixed: 'os_file_open' file descriptor mode being in decimal '660' when it should be octal '0600'
Added: Some "Zero-Is-Initialization" style error handling for some things
Maintenance: Tagged some functions as out of date/stale/needing review for validity
Fixed: Several asorted unspecified fixes for Linux platform layer

[Misc]
Added: Some missing from metagen base_string
[OS Linux]
Added: Rudimentary thread name setting
Documentation: Added 'Here Be Dragons' warning
Fixed: 'os_launch_process'
Fixed: Some assorted fixes and documentation/note tweaks
…es to get linux build going

[OS Linux]
Added: Missing implementation for 'os_properties_from_file_path'
Fixed: Accidentily leftover debugging code
Added: os_condition_variable_broadcast_
Removed: Some leftover debug stuff
Added: Misisng main function

[Font Freetype]
Added: Stubbed out files

[Demon Linux]
Added: Stubbed out files
Added: Implimented some functionality

[Build Script]
Added: freetype2 directory to include path
Added: freetype2 dynamic link

[Documentation]
Documentation: Wrote some notes with compiler flags

[Random]
Fixed: Clang complainting about unrelated B32 and U32 atomic types
Added: stb_image (could be temporary, not important right now)

[OS Core]
Fixed: Missing include guards

[Build Script]
Fixed: Erroring on a logging command
Added: Some logging to the build setup
Fixed: Added a zero-is-valid case for 'os_file_write'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant