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

build: tweak the build target on CIO_BACKEND_FILESYSTEM=Off #15

Closed
wants to merge 2 commits into from

Conversation

fujimotos
Copy link
Member

@fujimotos fujimotos commented Dec 27, 2018

This is a series of patch to make compilation on Windows easier.

344e18b build: do not build tools/cio if CIO_BACKEND_FILESYSTEM=Off
74ed9d2 build: also don't build "cio_utils.c" if CIO_BACKEND_FILESYSTEM=Off

Part of fluent/fluent-bit#960

Fujimoto Seiji added 2 commits December 27, 2018 17:13
Not only tools/cio has little use on platforms without file system
backend support, it causes the build to fail on these platforms.

Let's skip it.

Signed-off-by: Fujimoto Seiji <[email protected]>
This module contains a couple of functions for manipulating the file
system. We don't need them except the platform does support the file
system backend.

Signed-off-by: Fujimoto Seiji <[email protected]>
@edsiper
Copy link
Member

edsiper commented Jan 7, 2019

hi,

the tools system must be always enabled due to the following reason:

  • performance test: even if using memory only backend is important to be able to test read/write performance with different modifiers such as the checksum. This is a way to let the user test in isolation the better setup for them.

@fujimotos
Copy link
Member Author

fujimotos commented Jan 8, 2019

the tools system must be always enabled due to the following reason:

OK. Then I'll work on it so that we can run the perf test on Windows.

I think we need to get two things straight for that goal.

  1. Windows does not have getopt_long(), so we need to polyfill it.

  2. Functions in cio_utils.c are by and large not portable.
    We need to reimplement them using Win32 API.

For (1), we can probably make use of some existing implementation.
Here is a draft patch I created based on the one from musl libc (which
is MIT-licensed).

master...fujimotos:sf/getopt

What is your feeling about this? If you know a better alternative,
I will switch to it.

@edsiper
Copy link
Member

edsiper commented Jan 9, 2019

so likely fluent-bit.c will face the same issue, what other projects are doing to solve the options/arguments stuff in Windows ?

@cosmo0920
Copy link
Contributor

cosmo0920 commented Jan 9, 2019

@fujimotos
Copy link
Member Author

@edsiper For a cross-platform project originating from Unix world,
there seem to be two options.

  1. Implement own command-line option parser (git/vim/cmake etc.)
  2. Use a Windows-compatible getopt implementation (libevent etc.)

As to the first way, these projects essentially iterate args manually,
and throw a bunch of string comparisons. So they are quite portable
and don't require any platform-dependant fix.

https://github.com/git/git/blob/master/git.c#L124
https://github.com/vim/vim/blob/master/src/main.c#L1823

As to the second way, I see libevent contains a Windows compatible
implementation of getopt_long() (seems like grafted from somewhere
else, and not fully GNU/getopt compatible, though). Here is the code:

https://github.com/libevent/libevent/tree/master/WIN32-Code

I'm inclined to choose the option 2, mainly bacause chunkio and fluent-bit
uses getopt_long() already. This means we do not need no rewrite the
option parsing logic in main() for Windows compatibility.

@edsiper
Copy link
Member

edsiper commented Jan 9, 2019

thanks for the info. Looking around I've found that I've placed a getopt() clone in Monkey mk_core interface here:

https://github.com/monkey/monkey/tree/master/mk_core/external

since the bits are in place, we just need to add a getopt_long() clone to it as a new file, we just need to be careful about the license.

@fujimotos
Copy link
Member Author

https://github.com/monkey/monkey/tree/master/mk_core/external

OK. I go add a clone of getopt_long() there.

we just need to add a getopt_long() clone to it as a new file, we just need to be careful about the license.

Since several implementations are available, I'm going to investigate which clone is
preferable for our use case (incl. License), and do some testing on Windows.

Anyway, thanks for your review and comments. I'll close this ticket now.

@fujimotos
Copy link
Member Author

@edsiper I can confirm that we can run tools/cio on Windows
with the remaining #30, #31, #32, #33, #34, #35 and #36 merged,

I think chunkio is basically done porting, and we can bring the merged
HEAD to fluent-bit.

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.

3 participants