Export needed KenLM symbols manually for Windows

This commit is contained in:
Reuben Morais 2021-07-21 11:30:23 +02:00
parent b7428d114e
commit 7846f4602e
5 changed files with 20 additions and 7 deletions

View File

@ -78,7 +78,7 @@ tf_cc_shared_object(
"-std=c++11"
] + select({
"//tensorflow:windows": [],
"//conditions:default": ["-fvisibility=default"],
"//conditions:default": ["-fvisibility=hidden"],
}),
defines = ["KENLM_MAX_ORDER=6"],
includes = ["kenlm"],

View File

@ -23,7 +23,7 @@ extern const char *kModelNames[6];
* If so, return true and set recognized to the type. This is the only API in
* this header designed for use by decoder authors.
*/
bool RecognizeBinary(const char *file, ModelType &recognized);
KENLM_EXPORT bool RecognizeBinary(const char *file, ModelType &recognized);
struct FixedWidthParameters {
unsigned char order;

View File

@ -10,13 +10,19 @@
/* Configuration for ngram model. Separate header to reduce pollution. */
#if defined _MSC_VER
#define KENLM_EXPORT __declspec(dllexport)
#else
#define KENLM_EXPORT __attribute__ ((visibility("default")))
#endif /* _MSC_VER */
namespace lm {
class EnumerateVocab;
namespace ngram {
struct Config {
struct KENLM_EXPORT Config {
// EFFECTIVE FOR BOTH ARPA AND BINARY READS
// (default true) print progress bar to messages

View File

@ -149,7 +149,7 @@ typedef ProbingModel Model;
/* Autorecognize the file type, load, and return the virtual base class. Don't
* use the virtual base class if you can avoid it. Instead, use the above
* classes as template arguments to your own virtual feature function.*/
base::Model *LoadVirtual(const char *file_name, const Config &config = Config(), ModelType if_arpa = PROBING);
KENLM_EXPORT base::Model *LoadVirtual(const char *file_name, const Config &config = Config(), ModelType if_arpa = PROBING);
} // namespace ngram
} // namespace lm

View File

@ -10,9 +10,16 @@
#include <string>
#include <stdint.h>
#if defined _MSC_VER
#define KENLM_EXPORT __declspec(dllexport)
#else
#define KENLM_EXPORT __attribute__ ((visibility("default")))
#endif /* _MSC_VER */
namespace util {
class scoped_fd {
class KENLM_EXPORT scoped_fd {
public:
scoped_fd() : fd_(-1) {}
@ -82,7 +89,7 @@ class EndOfFileException : public Exception {
class UnsupportedOSException : public Exception {};
// Open for read only.
int OpenReadOrThrow(const char *name);
KENLM_EXPORT int OpenReadOrThrow(const char *name);
// Create file if it doesn't exist, truncate if it does. Opened for write.
int CreateOrThrow(const char *name);
@ -110,7 +117,7 @@ bool OutputPathIsStdout(StringPiece path);
// Return value for SizeFile when it can't size properly.
const uint64_t kBadSize = (uint64_t)-1;
uint64_t SizeFile(int fd);
KENLM_EXPORT uint64_t SizeFile(int fd);
uint64_t SizeOrThrow(int fd);
void ResizeOrThrow(int fd, uint64_t to);