Skip to content

Win32 build - stage 1. Core bootstrap.#90

Open
wlvchandler wants to merge 1 commit into
alexeilebedev:masterfrom
wlvchandler:win32_build_abt
Open

Win32 build - stage 1. Core bootstrap.#90
wlvchandler wants to merge 1 commit into
alexeilebedev:masterfrom
wlvchandler:win32_build_abt

Conversation

@wlvchandler

@wlvchandler wlvchandler commented Jul 14, 2024

Copy link
Copy Markdown
Collaborator

(Resubmitted with correct history)

Note - this is only the bootstrap portion to get a starting point for proper windows acr support. It successfully builds abt, src_hdr, src_func, and gcache build, but abt dies on an early error right now (will be handled in "stage 2"). the other binaries work as intended, verified by

  1. I wrapped all changes to cpp in #if defined(WIN32) blocks. I believe some of these changes would cause 0 issues on *nix builds - for example, casting - but better safe than sorry for now. That testing can occur later.
  2. The win32 build doesn't fit with the current workflow yet, so I added windows-specific .bat files. Dependencies are still being worked out, but this current commit just requires an openssl download (I added a script for a portable Perl download as well but it's unused)
  3. It does not work with MSVS GUI yet (at least, I haven't tried) - so the build process is running bin/win-ai.bat from the command line (works on CMD, PS and MSVS Dev command prompt):
  4. All 4 executables build, but the linker reports the following issues (TODO for next stage):
    • error LNK2019: unresolved external symbol
      • workaround for now: /FORCE:unresolved in linker argument (causes LNK4088 warning)
        • algo::Attr_ReadStrptrMaybe is user-defined
        • gcache: openssl/EVP symbols, Sha1Ctx::Sha1Ctx
    • warning LNK4042: object specified more than once; extras ignored
      • all lib.algo object files. not causing issues, but annoying
    • warning LNK4006: already defined in ; second definition ignored
      • cpp.gen.src_func_gen.obj, cpp.gen.gcache_gen.obj, cpp.gen.abt_gen.obj

      BTW - *nix builds remain unchanged. Hashes of the binaries change of course but I built and tested binaries with affected dependencies

@wlvchandler

Copy link
Copy Markdown
Collaborator Author

(force-pushed a change w/ updated gitfile)

Comment thread cpp/lib/algo/string.cpp
prev = num;
num = num*16 + val;
overflow |= num<prev;
num = num*(u64)16 + (u64)val;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

type of num could be u128 here

Comment thread cpp/lib/algo/win32.cpp
return ret;
}

#if ! defined(WIN32)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

is the test reversed here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, but actually the function override is unnecessary at all - isatty() is deprecated and _isatty() is now preferred so I'm replacing the dummy definition with a conditional #define for win32 instead

Comment thread cpp/lib/algo/win32.cpp
}
dir->iter=0;
dir->eof=dir->handle == INVALID_HANDLE_VALUE;
//dir->path = _strdup(path);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

delete any dead code

Comment thread cpp/lib/algo/win32.cpp

} ThreadParams;

int pthread_create(pthread_t *thread, pthread_attr_t *attr, ThreadFunc func, void *arg) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

looks like pthread_* is unused, it can be deleted in its entirety

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The functions are somewhat incomplete implementations (I can do it in full in another PR), but don't we want to offer the library functionality? Or - prefer keeping the single-threaded paradigm?

Comment thread include/algo.inl.h
static BOOL qpc = QueryPerformanceCounter(&freq);
if (qpc) {
LARGE_INTEGER t_now;
QueryPerformanceCounter(&t_now);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why is the function called twice?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch - first one should be QueryPerformanceFrequency(&freq)

Comment thread include/algo.inl.h



/*

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

delete this

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.

2 participants