Don't use external symbol names in internal files
authorNikolaus Rath <Nikolaus@rath.org>
Tue, 19 Sep 2017 15:24:37 +0000 (16:24 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 19 Sep 2017 15:47:40 +0000 (16:47 +0100)
The fuse_session_loop_mt() and fuse_loop_mt() symbols are only visible
when linking against the shared object. The code in lib/, however, is
compiled *into* the shared object and should thus use the internal
names of these functions.

Surprisingly enough, the code still worked before - but only when link
time optimization was disabled.

Unfortunately, we still can't compile with LTO because it seems that
enabling LTO somehow makes the tagged symbols vanish.

Without lto, we have:

$ nm lib/libfuse3.so | grep fuse_new
0000000000011070 T fuse_new_30
0000000000010a00 t fuse_new_31
0000000000011070 T fuse_new@FUSE_3.0
0000000000010a00 T fuse_new@@FUSE_3.1

and with LTO:

$ nm lib/libfuse3.so | grep fuse_new
0000000000019a70 T fuse_new_30
0000000000019270 t fuse_new_31

See also issue #198.

lib/cuse_lowlevel.c
lib/fuse.c
lib/fuse_i.h
lib/fuse_loop_mt.c
lib/helper.c

index 19b2ab653a9c4d88d10a72381964c6e9c3c44e6c..56e6aa9d243c14171ffa320e67825ce2a0bf8b5e 100644 (file)
@@ -353,7 +353,7 @@ int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci,
                struct fuse_loop_config config;
                config.clone_fd = 0;
                config.max_idle_threads = 10;
-               res = fuse_session_loop_mt(se, &config);
+               res = fuse_session_loop_mt_32(se, &config);
        }
        else
                res = fuse_session_loop(se);
index 75ae38ade5c12838ba51a1c32c91e3aeb6d32408..47a99612974bca7a491d210ca04b7ad8bf86c237 100644 (file)
@@ -4382,7 +4382,6 @@ int fuse_loop(struct fuse *f)
        return fuse_session_loop(f->se);
 }
 
-int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
 FUSE_SYMVER(".symver fuse_loop_mt_32,fuse_loop_mt@@FUSE_3.2");
 int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config)
 {
@@ -4393,7 +4392,7 @@ int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config)
        if (res)
                return -1;
 
-       res = fuse_session_loop_mt(fuse_get_session(f), config);
+       res = fuse_session_loop_mt_32(fuse_get_session(f), config);
        fuse_stop_cleanup_thread(f);
        return res;
 }
@@ -4683,8 +4682,6 @@ void fuse_stop_cleanup_thread(struct fuse *f)
 }
 
 
-/* Explicit prototype to prevent compiler warnings
-   (fuse.h only defines fuse_new()) */
 FUSE_SYMVER(".symver fuse_new_31,fuse_new@@FUSE_3.1");
 struct fuse *fuse_new_31(struct fuse_args *args,
                      const struct fuse_operations *op,
index 80849ec8182f5fbf8e7da549395a84760d40b392..cf3555168234e10d463c29ab6d04c4997d5f4bc1 100644 (file)
@@ -128,3 +128,6 @@ void fuse_session_process_buf_int(struct fuse_session *se,
 
 struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op,
                      size_t op_size, void *private_data);
+int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
+int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
+
index 904539eff37f1e85a46668548ea1ac8dd8a28797..731fcf589e5786b5cb97fbb7f703439fdefa6f4e 100644 (file)
@@ -301,7 +301,6 @@ static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w)
        free(w);
 }
 
-int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
 FUSE_SYMVER(".symver fuse_session_loop_mt_32,fuse_session_loop_mt@@FUSE_3.2");
 int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config)
 {
index cb7aebccaf6dfa615d108da66a0f29d91c544496..3627749e49dba310bdbcec52e75a8d8135c12a62 100644 (file)
@@ -336,7 +336,7 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
                struct fuse_loop_config loop_config;
                loop_config.clone_fd = opts.clone_fd;
                loop_config.max_idle_threads = opts.max_idle_threads;
-               res = fuse_loop_mt(fuse, &loop_config);
+               res = fuse_loop_mt_32(fuse, &loop_config);
        }
        if (res)
                res = 1;