Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/include/emscripten/val.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct WireTypePack {
static const char name##_symbol[] = #name; \
static const ::emscripten::internal::symbol_registrar<name##_symbol> name##_registrar

class val {
class EMBIND_VISIBILITY_DEFAULT val {
public:
// missing operators:
// * ~ - + ++ --
Expand Down
3 changes: 2 additions & 1 deletion system/include/emscripten/wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string>

#define EMSCRIPTEN_ALWAYS_INLINE __attribute__((always_inline))
#define EMBIND_VISIBILITY_DEFAULT __attribute__((visibility("default")))

#ifndef EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES
#define EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES 1
Expand Down Expand Up @@ -430,7 +431,7 @@ constexpr bool typeSupportsMemoryView() {
} // namespace internal

template<typename ElementType>
struct memory_view {
struct EMBIND_VISIBILITY_DEFAULT memory_view {
memory_view() = delete;
explicit memory_view(size_t size, const ElementType* data)
: size(size)
Expand Down
30 changes: 30 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7718,6 +7718,36 @@ def test_source_map(self, args):
else:
self.assertTrue(seen_lines.issuperset([6, 7, 11, 12]), seen_lines)

@needs_dylink
def test_embind_dylink_visibility_hidden(self):
# Check that embind is usable from a library built with "-fvisibility=hidden"

create_file('liblib.cpp', r'''
#include <emscripten/val.h>
#define EXPORT __attribute__((visibility("default")))
using namespace emscripten;
EXPORT void liba_fun() {
unsigned char buffer[1];
val view(typed_memory_view(1, buffer));
}
''')
self.build_dlfcn_lib('liblib.cpp', emcc_args=['-fvisibility=hidden'])

self.prep_dlfcn_main()
self.clear_setting('NO_AUTOLOAD_DYLIBS')
create_file('main.cpp', r'''
#include <stdio.h>
#include <emscripten/val.h>
using namespace emscripten;
void liba_fun();
int main() {
liba_fun();
printf("done\n");
return 0;
}
''')
self.do_runf('main.cpp', 'done\n', emcc_args=['--bind'])

@no_wasm2js('TODO: source maps in wasm2js')
def test_dwarf(self):
self.emcc_args.append('-g')
Expand Down