Skip to content

[src] changes to make kaldi can be installed on cygwin#2304

Merged
danpovey merged 13 commits intokaldi-asr:masterfrom
qbetterk:to-merge
Apr 5, 2018
Merged

[src] changes to make kaldi can be installed on cygwin#2304
danpovey merged 13 commits intokaldi-asr:masterfrom
qbetterk:to-merge

Conversation

@qbetterk
Copy link
Contributor

mostly the job is to add "defined(CYGWIN)" when needed and choose correct function as compiled on cygwin.

One thing worth noticing is that there is a line of code should be changed in "/usr/include/ctype.h". (still the problem of add "defined(CYGWIN)"). But this seems a problem of cygwin itself. Maybe user need to add it manually.

#if defined(_MSC_VER) || defined(MINGW)
::Sleep(static_cast<int>(seconds * 1000.0));
#elif defined(__CYGWIN__)
kaldi::Sleep(static_cast<int>(seconds * 1000.0));
Copy link
Contributor

@danpovey danpovey Mar 23, 2018

Choose a reason for hiding this comment

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

this makes me think you haven't run the tests ("make test"). It would just recurse and crash when it exceeds the max stack depth.
Try doing "man usleep" or "man -k sleep" in cygwin, assuming man pages are installed, to see what sleep functions are available and what you have to include to find them.


#ifdef __CYGWIN__
static pclose(FILE* file) {
//FILE *file = (FILE*)_file;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the purpose of this function -- seems almost like a recursive call or somethign
y.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, this change(about 'popen' and 'pclose') is a mistake. The original code was right. I find that what I need to change is in the /usr/include/stdio.h rather than in kaldi.

@qbetterk
Copy link
Contributor Author

@hainan-xv Can you review this?

# Overwrite ./version.h with the temporary file if they are different.
if ! cmp -s $temp version.h; then
cp $temp version.h
sed -i 's/\r//g' version.h
Copy link
Contributor

Choose a reason for hiding this comment

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

try to avoid sed -i (or sed altogether)

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, try to figure out where the linefeed character comes from originally (does 'echo' add it?) and I'd like to know what problems it causes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but there would be '\r' in the 'version.h' file since it is on windows. should I leave it to users to delete '\r' themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kaldi itself does not have '\r'. this character is automatically generated when I download kaldi to a windows machine. '\r' in windows means 'end of line' like '\n' in Unix and the Unix environment(cygwin) cannot recognize it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think the logic of your change is wrong, your code will cause
the if ! cmd test always succeed, so you will always replace the file --
you should modify the $temp file instead

@jtrmal
Copy link
Contributor

jtrmal commented Mar 30, 2018 via email

@danpovey
Copy link
Contributor

danpovey commented Mar 30, 2018 via email

@jtrmal
Copy link
Contributor

jtrmal commented Mar 30, 2018 via email

@jtrmal
Copy link
Contributor

jtrmal commented Mar 30, 2018 via email

@qbetterk
Copy link
Contributor Author

qbetterk commented Mar 30, 2018 via email

@jtrmal
Copy link
Contributor

jtrmal commented Mar 30, 2018 via email

@qbetterk
Copy link
Contributor Author

qbetterk commented Mar 30, 2018 via email

} else if (tmp == 1) {
return LatticeWeight( 1, 2); // sometimes return special values..
} else if (tmp == 2) {
return LatticeWeight( 2, 1); // this tests more thoroughly certain properties...
Copy link
Contributor

Choose a reason for hiding this comment

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

you're not supposed to use \tab in the code; use 2 spaces instead.

@jtrmal
Copy link
Contributor

jtrmal commented Apr 2, 2018

Yes, please read the Google Style Guide for C++

@qbetterk
Copy link
Contributor Author

qbetterk commented Apr 2, 2018 via email

Copy link
Contributor

@danpovey danpovey left a comment

Choose a reason for hiding this comment

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

A couple of comments. please check with (e.g.) Hainan if you're unsure what I mean or how to do something.

#if defined(_MSC_VER) || defined(MINGW)
::Sleep(static_cast<int>(seconds * 1000.0));
#elif defined(__CYGWIN__)
sleep(static_cast<int>(seconds * 1.0));
Copy link
Contributor

Choose a reason for hiding this comment

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

the * 1.0 here is unnecessary.

# define KALDI_MEMALIGN_FREE(x) _aligned_free(x)
#elif defined(__CYGWIN__)
# define KALDI_MEMALIGN(align, size, pp_orig) \
(*(pp_orig) = aligned_alloc(align, size))
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I now see that we don't need this macro at all any more, as aligned_alloc is part of the C++11 standard. So please remove the macro and replace all instances of
foo = KALDI_MEMALIGN(x, y, &z)
with
foo = aligned_alloc(x, y);
and remove the temporary variables that previously bound to z, and replace KALDI_MEMALIGN_FREE with free (there are instances of this in the cudamatrix/ directory as well, that should also be replaced).

@qbetterk
Copy link
Contributor Author

qbetterk commented Apr 4, 2018 via email

@jtrmal
Copy link
Contributor

jtrmal commented Apr 5, 2018 via email

@qbetterk
Copy link
Contributor Author

qbetterk commented Apr 5, 2018 via email

@danpovey danpovey merged commit 1a1e265 into kaldi-asr:master Apr 5, 2018
danpovey added a commit to danpovey/kaldi that referenced this pull request Apr 10, 2018
danpovey added a commit to danpovey/kaldi that referenced this pull request Apr 10, 2018
LvHang pushed a commit to LvHang/kaldi that referenced this pull request Apr 14, 2018
LvHang pushed a commit to LvHang/kaldi that referenced this pull request Apr 14, 2018
Skaiste pushed a commit to Skaiste/idlak that referenced this pull request Sep 26, 2018
Skaiste pushed a commit to Skaiste/idlak that referenced this pull request Sep 26, 2018
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.

4 participants