Repository: RustPython/RustPython (language: rust)

Issue:
Build fails: ld: error: undefined symbol: daylight
## Summary

The build fails:
```
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/local/lib/rustlib/x86_64-unknown-freebsd/bin:/usr/local/lib/rustlib/x86_64-unknown-freebsd/bin:/usr/local/lib/rustlib/x86_64-unknown-freebsd/bin:/wrkdirs/usr/ports/lang/rustpython/work/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/nonexistent/bin" VSLANG="1033" "cc" "-m64" "/wrkdirs/usr/ports/lang/rustpython/work/rustcXSXEia/symbols.o" "/wrkdirs/usr/ports/lang/rustpython/work/target/release/deps/rustpython-7cef36e1a901205c.rustpython.22b23ddfe634e088-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/wrkdirs/usr/ports/lang/rustpython/work/target/release/deps" "-L" "/wrkdirs/usr/ports/lang/rustpython/work/target/release/build/libsqlite3-sys-c29a8fd6e544aa09/out" "-L" "/usr/local/lib/rustlib/x86_64-unknown-freebsd/lib" "-Wl,-Bstatic" "/wrkdirs/usr/ports/lang/rustpython/work/rustcXSXEia/liblibsqlite3_sys-62720dff646e4724.rlib" "/usr/local/lib/rustlib/x86_64-unknown-freebsd/lib/libcompiler_builtins-989cb5940426e9a9.rlib" "-Wl,-Bdynamic" "-lc" "-lz" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/local/lib/rustlib/x86_64-unknown-freebsd/lib" "-o" "/wrkdirs/usr/ports/lang/rustpython/work/target/release/deps/rustpython-7cef36e1a901205c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-fstack-protector-strong"
  = note: ld: error: undefined symbol: daylight
          >>> referenced by rustpython.22b23ddfe634e088-cgu.0
          >>>               /wrkdirs/usr/ports/lang/rustpython/work/target/release/deps/rustpython-7cef36e1a901205c.rustpython.22b23ddfe634e088-cgu.0.rcgu.o:(rustpython_vm::stdlib::time::decl::extend_module::ha6516acecbf587b0)
          cc: error: linker command failed with exit code 1 (use -v to see invocation)
```

## Details

[log](https://freebsd.org/~yuri/rustpython-0.4.0.log)

0.3.1 didn't have such problem.

Version: 0.4.0
FreeBSD 14.1



Discussion / hints:

Fix patch:
diff --git a/vm/src/stdlib/time.rs b/vm/src/stdlib/time.rs
index a5e21819b8..566650d0f2 100644
--- a/vm/src/stdlib/time.rs
+++ b/vm/src/stdlib/time.rs
@@ -18,6 +18,7 @@ pub(crate) fn make_module(vm: &VirtualMachine) -> PyRef<PyModule> {
 #[cfg(not(target_env = "msvc"))]
 #[cfg(not(target_arch = "wasm32"))]
 extern "C" {
+    #[cfg(not(target_os = "freebsd"))]
     #[link_name = "daylight"]
     static c_daylight: std::ffi::c_int;
     // pub static dstbias: std::ffi::c_int;
@@ -163,6 +164,7 @@ mod decl {
         unsafe { super::c_timezone }
     }
 
+    #[cfg(not(target_os = "freebsd"))]
     #[cfg(not(target_env = "msvc"))]
     #[cfg(not(target_arch = "wasm32"))]
     #[pyattr]


Test patch: